S2EdgeCrosser.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 chain of other edges, it is slightly more efficient to use the single-argument version of CrossingSign below.

The arguments must point to values that persist until the next call.

  1. int crossingSign(S2Point c, S2Point d)
    class S2EdgeCrosser
    int
    crossingSign
    (
    ref in S2Point c
    ,
    ref in S2Point d
    )
  2. int crossingSign(S2Point d)

Meta