2

I came across this link http://www.mathopenref.com/coordpolygonarea2.html

It explains how to calculate the area of a polygon and helps to identify whether the polygon vertices we entered is clockwise or counter clockwise.

If area value is +ve, it is clockwise, if it is -nv then it is in counterclockwise.

My requirement is to identify only whether it is clockwise or counterclockwise. Is this rule will work correctly (though there are limitations as mentioned in the link). I have only regular polygons (not complicated, no self intersections) but the vertices are more.

I am not interested in the area value accuracy, just to know the ring rotation.

Any other thought on this.

vadivelan p
  • 123
  • 1
  • 3
  • possible duplicate of [How to determine if a list of polygon points are in clockwise order?](http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order) – Phrogz Apr 06 '12 at 20:59
  • Here is a link to a similar problem that was solved. [http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order][1] [1]: http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order – triple_t91 Dec 31 '13 at 05:19

2 Answers2

9

For convex polygons:

Select two edges with a common vertex. 
Lets say, edge1 is between vertex A and B. Edge2 is between vertex B and C.
Define to vectors: vect1: A----->B
                   vect2: B----->C
Cross product vect1 and vect2. 
If the result is positive, the sequence A-->B-->C is Counter-clockwise. 
If the result is negative, the sequence A-->B-->C is clockwise. 
delete_this_account
  • 2,376
  • 7
  • 23
  • 31
5

If you have only convex polygons (and all regular polygons are convex), and if your points are all organized consistently--either all counterclockwise or all clockwise--then you can determine which by just computing the (signed) area of one triangle determined by any three consecutive points. This is essentially computing the cross product of the two vectors along the two edges.

Joseph O'Rourke
  • 4,346
  • 16
  • 25