Given a list of x,y co-ordinates for a polygon, how can I tell if those points are listed clockwise, or anticlockwise?
Background - I'm trying to test if a drone has breached a geo-fence. I have the x,y co-ordinates of the drone, and I have the x,y co-ordinates of each corner of the geo-fence.
I'm following on from this post about how to determine if a point is to the left or right of a line. It follows that if a point is to the right of every side of a polygon then that point must be within that polygon. However, to get this work, I need make sure that I know the direction (clockwise or anti-clockwise) that those points are list in.
Consider these three points.... p0(1,1) p1(2,6) p2(4,1) I've listed them in a clockwise fashion, if my drone is to the right of the line p0-p1, and to the right of p1-p2, and the right of p2-p0, then the drone within the geofence. But this is only true if the points are listed clockwise. How do I check this is true?