Hi all,
I'm working on an open source tracking and geofence software application and am having a bit of difficulty figuring out the math for the geofencing.
I need to determine whether or not a coordinate exists inside of a polygon. However, the tricky part is that the polygon has no set number of sides. I need to be able to calculate for fifty sides or for five sides.
My research says that the easiest way is to take my point (which I'll call x) and a point outside the polygon (call it y) and determine if line ((xx, xy), (yx, yy)) intersects with the polygon's boundaries. If it intersects an odd number of times, point x must be inside the polygon.
Knowing that, however, I cannot figure out how to express this in an algorithm.. I obviously will need to loop through the various lines constructing the polygon but the check I do eludes me. Can anyone be of assistance? Please know that I'm not asking for the solution necessarily. Anything that will help me figure it out the answer is an enormous help.
Much appreciated.