Jeff Massung wrote:
Michael,

I assume you are talking about 2D polygons...

Just take a 3D cross product of the first two vector (P3 - P2) x (P2 - P1).
If the resultant vector is coming out of the screen (Z < 0) then the polygon
is counter-clockwise. If it is going into the screen (Z > 0) then the
polygon is clockwise.

http://chortle.ccsu.edu/VectorLessons/vch12/vch12_1.html

That page may be of help if you don't know what the cross product is. Note:
to do the 3D cross product, just use Z=0 for all the points.

Well, I confess I don't properly remember what the cross-product is, so I will go read that page.

But even without doing so, I am sure that this can't be a correct solution; the following two polygons have opposite flow, but P1, P2 and P3 are the same

0,0; 100,0; 100,100; 0,0    (i.e. a counter-clockwise triangle)
0,0; 100,0; 100,100; 200,100; 200,-10; 0,-10; 0,0 (i.e. a clockwise L-shape)

I'll post a couple of suggested solutions shortly (once I've got the stack running properly)

-- Alex.

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to