The following code fails intersection and returns an empty array:
const poly1 = [[
[0, 0],
[1, 0],
[1, 1],
[0, 1],
[0, 0]
]];
const poly2 = [[
[0.5, 0.0],
[0.6, 0.5],
[0.7, 0.5],
[0.5, 0.0]
]];
const intersectionPolygon = martinezPolygonClipping.intersection(poly1, poly2);
In the above case, the poly2 can be interpreted as "leaning right", with exactly 1 vertex at the southern edge.
However, when running with poly2 "leaning left", this passes.
const poly2 = [[
[0.5, 0.0],
[0.4, 0.5],
[0.3, 0.5],
[0.5, 0.0]
]];
It also passes when the vertex is not on the southern edge.
const poly2 = [[
[0.5, 0.00001], // Both +0.00001 and -0.0001 pass
[0.6, 0.5],
[0.7, 0.5],
[0.5, 0.00001]
]];
The following code fails intersection and returns an empty array:
In the above case, the poly2 can be interpreted as "leaning right", with exactly 1 vertex at the southern edge.
However, when running with poly2 "leaning left", this passes.
It also passes when the vertex is not on the southern edge.