Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

polygon vertices - clockwise or counterclockwise

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.

like image 243
vadivelan p Avatar asked Feb 16 '26 13:02

vadivelan p


1 Answers

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. 
like image 115
delete_this_account Avatar answered Feb 21 '26 11:02

delete_this_account



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!