Detecting winding of an arbitrry polygon

This topic is 3601 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Given a closed 2d polygon how can I tell if its clockwise or counter clockwise? I'm feeding it to a triangulation routine which requires a certain winding. Right now the best I ahve come up with is feed it to the triangulation and throw away the result that has fewer triangles ;-) Seems like something I should be able to tell in advance and my google voodo has not come up with the right magic words.

Share on other sites
Calculate the normal from 2 edge vectors and compare it with the actual normal of the polygon: (((v0-v1) cross (v2-v1)) dot orig_normal) > 0.

Should work...

Share on other sites
Which 2 edges though? I believe that only works for a convex polygon. For a concave one you might just be on an inside corner.

Share on other sites
Quote:
 Original post by Nutterhm, good point. This should do the trick then: http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/

I wondered why you sent me to the area algorithm, until I read this one http://local.wasp.uwa.edu.au/~pbourke/geometry/clockwise/index.html#clockwise

Thats a great site - thanks.... google must pass him by (or rank him prety low)

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 37
• 12
• 12
• 11
• Forum Statistics

• Total Topics
631414
• Total Posts
2999952
×