# Distinguish between clockwise and counterclockwise polygon

When using land information data such as polygons presented as arrays of points, sometimes I need to know whether a polygon's points turn clockwise or counter-clockwise. Please tell me what kind of algorithm could help with this

• If the polygon is convex it is enough to check the cross product of any two given consecutive edges, treated as vectors with the same origin. For polygon $ABCDE$ it would be $CB \times CD$ Nov 25, 2014 at 11:07
• Assuming your polygons are simple ("land information data" indicates this might be the case), you can calculate their signed area and check its sign, e.g. see here. Nov 25, 2014 at 11:15
• dtldarek thank you! Why do you put a comment instead of answering? I'd mark your answer as best one Dec 2, 2014 at 16:31

Assuming your polygons are simple ("land information data" indicates this might be the case), you can calculate their signed area as $$A = \frac12 (x_1y_2-x_2y_1+x_2y_3-x_2y_2 + \dots + x_ny_1-x_1y_n)$$ and check its sign (positive means counterclockwise). The formula is found on Wolfram MathWorld. -- dtldarek