// based on http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
// check if input is inside polygon
// points is an array of polygon points; input is point to check if its iside polygon
boolean checkPointInsidePolygon(Point[] points, PVector input)
{
int i, j;
boolean c = false;
for (i = 0, j = points.length-1; i < points.length; j = i++) {
if ( ((points[i].y>input.y) != (points[j].y>input.y)) &&
(input.x < (points[j].x-points[i].x) * (input.y-points[i].y) / (points[j].y-points[i].y) + points[i].x) )
c = !c;
}
return c;
}
}
pass ofPath points instead of Point[] points as a parameter
Hey, thanks for the tip.
I was more looking for an oF integrated solution (if it exists)
I will have a look at it. Quite theoretical though, but really interesting.
For now i am just converting the path into an ofPolyline when needed in order to be able to use the inside() method… but seems a messy solution…