Andy Burton - 2013-07-05 16:45:04
Bit of an odd one but there seem to be some scenarios that cause isPolyInside to incorrectly identify another polygon that is inside it e.g.
// Polygon coordinates
$coordsA = array (
array (5,5), array (15,2),
array (15,10), array (5,10)
);
$coordsB = array (
array (9,5), array (11,5),
array (11,7), array (9,7)
);
// Create polygons
$pA = new polygon;
$pB = new polygon;
foreach ($coordsA as $coord)
{
$pA->addv ($coord[0], $coord[1]);
}
foreach ($coordsB as $coord)
{
$pB->addv ($coord[0], $coord[1]);
}
// Check whether B is inside A
// This should return TRUE but instead returns FALSE
var_dump ($pA->isPolyInside ($pB));
If i change $point_at_infinity in polygon->isInside() to be 10000000 vs -10000000 as it is originally then it works correctly, HOWEVER this causes failures in other scenario's that would normally work.
I'm not certain what the problem is as i haven't gone as far as understanding the maths behind it, but i can't seem to get it working correctly in all situations regardless of what i try