We have some set of point coordinates in lat/long which contribute to a polygon. From this set how do we determine the polygon is clockwise or anticlockwise?
- 1Given that there are valid cases where a single polygon can be counter clockwise, there's no real way to tell if a polygon is 'clockwise' or 'counterclockwise' without some level of implied knowledge. However, what you're looking for is the 'envelope angle' of your polygon. If it's greater than 90°, then it's 'counterclockwise', otherwise 'clockwise'. Depending on your platform, there are different ways of finding this out. One way would be to ensure that all your data is stored in a valid format before sending it to the client.nagytech– nagytech2015-06-09 12:39:31 +00:00Commented Jun 9, 2015 at 12:39
- 1@nagytech No, it is trivial to determine ring orientation -- Calculate the area using the trapezoid rule (or zipper algorithm); negative area is opposite orientation of positive areaVince– Vince2015-06-09 12:59:23 +00:00Commented Jun 9, 2015 at 12:59
- 1Check again, I never said any operation was non-trivial. Regardless, calculating the envelope angle is immensely more efficient than calculating the area of a polygon.nagytech– nagytech2015-06-09 13:25:52 +00:00Commented Jun 9, 2015 at 13:25
- You wrote "there's no real way to tell if a polygon is 'clockwise' or 'counterclockwise' without some level of implied knowledge", which is incorrect.Vince– Vince2015-06-09 18:50:11 +00:00Commented Jun 9, 2015 at 18:50
- Here is a discussion on stack overflow.Hornbydd– Hornbydd2015-06-09 22:30:36 +00:00Commented Jun 9, 2015 at 22:30
| Show 1 more comment