Given two edges AB and CD where at least two vertices are identical
(i.e. CrossingSign(a,b,c,d) == 0), this function defines whether the
two edges "cross" in a such a way that point-in-polygon containment tests
can be implemented by counting the number of edge crossings. The basic
rule is that a "crossing" occurs if AB is encountered after CD during a
CCW sweep around the shared vertex starting from a fixed reference point.
Note that according to this rule, if AB crosses CD then in general CD
does not cross AB. However, this leads to the correct result when
counting polygon edge crossings. For example, suppose that A,B,C are
three consecutive vertices of a CCW polygon. If we now consider the edge
crossings of a segment BP as P sweeps around B, the crossing number
changes parity exactly when BP crosses BA or BC.
Useful properties of VertexCrossing (VC):
(1) VC(a,a,c,d) == VC(a,b,c,c) == false
(2) VC(a,b,a,b) == VC(a,b,b,a) == true
(3) VC(a,b,c,d) == VC(a,b,d,c) == VC(b,a,c,d) == VC(b,a,d,c)
(3) If exactly one of a,b equals one of c,d, then exactly one of
VC(a,b,c,d) and VC(c,d,a,b) is true
It is an error to call this method with 4 distinct vertices.
Given two edges AB and CD where at least two vertices are identical (i.e. CrossingSign(a,b,c,d) == 0), this function defines whether the two edges "cross" in a such a way that point-in-polygon containment tests can be implemented by counting the number of edge crossings. The basic rule is that a "crossing" occurs if AB is encountered after CD during a CCW sweep around the shared vertex starting from a fixed reference point.
Note that according to this rule, if AB crosses CD then in general CD does not cross AB. However, this leads to the correct result when counting polygon edge crossings. For example, suppose that A,B,C are three consecutive vertices of a CCW polygon. If we now consider the edge crossings of a segment BP as P sweeps around B, the crossing number changes parity exactly when BP crosses BA or BC.
Useful properties of VertexCrossing (VC):
(1) VC(a,a,c,d) == VC(a,b,c,c) == false (2) VC(a,b,a,b) == VC(a,b,b,a) == true (3) VC(a,b,c,d) == VC(a,b,d,c) == VC(b,a,c,d) == VC(b,a,d,c) (3) If exactly one of a,b equals one of c,d, then exactly one of VC(a,b,c,d) and VC(c,d,a,b) is true
It is an error to call this method with 4 distinct vertices.