crossingSign

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.

Note that if an edge is degenerate (A == B or C == D), the return value is 0 if two vertices from different edges are the same and -1 otherwise.

Properties of CrossingSign:

(1) CrossingSign(b,a,c,d) == CrossingSign(a,b,c,d) (2) CrossingSign(c,d,a,b) == CrossingSign(a,b,c,d) (3) CrossingSign(a,b,c,d) == 0 if a==c, a==d, b==c, b==d (3) CrossingSign(a,b,c,d) <= 0 if a==b or c==d (see above)

This function implements an exact, consistent perturbation model such that no three points are ever considered to be collinear. This means that even if you have 4 points A, B, C, D that lie exactly in a line (say, around the equator), C and D will be treated as being slightly to one side or the other of AB. This is done in a way such that the results are always consistent (see s2pred::Sign).

Note that if you want to check an edge against a collection of other edges, it is much more efficient to use an S2EdgeCrosser (see s2edge_crosser.h).

int
crossingSign

Meta