View Full Version : How do I determine Clockwise rotation of vertexes

08-11-2000, 07:19 AM
Can someone help me with a quick formula or even a short explanation on how I would determine the order of vertexes in a 3D space. I'd like to do this so that I can reorder all my vertexes to be in counter clockwise order.

for a little more explanation if needed, I am only using triangles, so I only have 3 points for each triangle which I would like to reorder.

So if I have (0,0,0), (1,0,0) and (1,1,0). How can I make sure they go in the right order as above or one of the other 2 possibilities and not in the wrong order such as (1,1,0) (1,0,0) (0,0,0) or (1,0,0) (0,0,0) (1,1,0).

Any ideas?


Korin Bampton

08-11-2000, 07:55 AM
Well I only got 3 hours of sleep last night so if this is confusing bear with me...
This assumes the positive z axis is "up".
Take your 3 vertices v1,v2,v3
(each of which has components .x, .y, .z)
vector1 = v2-v1;
vector2 = v3-v1
vector3 = vector1 X vector2 (cross product)
if vector3.z > 0, then all is well,
otherwise, swap vertices 2 and 3, then all will be well.
Oh and I think you meant COUNTER clockwise, as this is the default orientation of OpenGL.
This example ensures counterclockwise orientation.
If you don't know what any of this means, I encourage you to learn linear algebra THEN come back to OpenGL - it will save you time in the long run.

08-11-2000, 08:44 AM
Which side is the front face and which is the back face (along with the chirality of the axes), determines which direction is clockwise and which is counter-clockwise. Just using the z axis as a reference is not enough.