S2EdgeCrosser

This class allows edges to be efficiently tested for intersection with a given fixed edge AB. It is especially efficient when testing for intersection with an edge chain connecting vertices v0, v1, v2, ...

Example usage:

void CountIntersections(const S2Point& a, const S2Point& b, const vector<pair<S2Point, S2Point>>& edges) { int count = 0; S2EdgeCrosser crosser(&a, &b); for (const auto& edge : edges) { if (crosser.CrossingSign(&edge.first, &edge.second) >= 0) { ++count; } } return count; }

This class expects that the client already has all the necessary vertices stored in memory, so that this class can refer to them with pointers and does not need to make its own copies. If this is not the case (e.g., you want to pass temporary objects as vertices), see S2CopyingEdgeCrosser.

Constructors

this
this()
Undocumented in source.
this
this(S2Point a, S2Point b)
Undocumented in source.
this
this(S2Point a, S2Point b, S2Point c)

Convenience constructor that uses AB as the fixed edge, and C as the first vertex of the vertex chain (equivalent to calling RestartAt(c)).

Members

Functions

a
const(S2Point*) a()
Undocumented in source. Be warned that the author may not have intended to support it.
b
const(S2Point*) b()
Undocumented in source. Be warned that the author may not have intended to support it.
crossingSign
int crossingSign(S2Point c, S2Point d)

This function determines whether the edge AB intersects the edge CD. Returns +1 if AB crosses CD at a point that is interior to both edges. Returns 0 if any two vertices from different edges are the same. Returns -1 otherwise.

crossingSign
int crossingSign(S2Point d)

Like CrossingSign above, but uses the last vertex passed to one of the crossing methods (or RestartAt) as the first vertex of the current edge.

edgeOrVertexCrossing
bool edgeOrVertexCrossing(S2Point d)

Like EdgeOrVertexCrossing above, but uses the last vertex passed to one of the crossing methods (or RestartAt) as the first vertex of the current edge.

edgeOrVertexCrossing
bool edgeOrVertexCrossing(S2Point c, S2Point d)

This method extends the concept of a "crossing" to the case where AB and CD have a vertex in common. The two edges may or may not cross, according to the rules defined in VertexCrossing() below. The rules are designed so that point containment tests can be implemented simply by counting edge crossings. Similarly, determining whether one edge chain crosses another edge chain can be implemented by counting.

initialize
void initialize(S2Point a, S2Point b)
Undocumented in source. Be warned that the author may not have intended to support it.
restartAt
void restartAt(S2Point c)

Call this method when your chain 'jumps' to a new place. The argument must point to a value that persists until the next call.

Properties

c
const(S2Point)* c [@property getter]

Returns the last vertex of the current edge chain being tested, i.e. the C vertex that will be used to construct the edge CD when one of the methods above is called.

Meta