Sign in to follow this  
thezbuffer

Detecting winding of an arbitrry polygon

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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Nutter
hm, 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)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this