Having a list of points, how do I find if they are in clockwise order?
For example:
point[0] = (5,0)
point[1] = (6,4)
point[2] = (4,5)
point[3] = (1,5)
point[4] = (1,0)
would say that it is anti-clockwise (or counter-clockwise, for some people).
Here's swift 3.0 solution based on answers above:
find the center of mass of these points.
suppose there are lines from this point to your points.
find the angle between two lines for line0 line1
than do it for line1 and line2
...
...
if this angle is monotonically increasing than it is counterclockwise ,
else if monotonically decreasing it is clockwise
else (it is not monotonical)
you cant decide, so it is not wise
C# code to implement lhf's answer:
An implementation of Sean's answer in JavaScript:
Pretty sure this is right. It seems to be working :-)
Those polygons look like this, if you're wondering: