Triangle Winding

Started by
9 comments, last by cjmaxwell 20 years ago
if the vertices are not too dodgy, calcualte the barycentric centre (Centre = (V[0] + V[1] + V[3] + ....) / Number_of_Vertices), and calculate the angle of each vertices from the X axis, sort them by angle value, then they should be listed anticlockwise.

Vector V[6];float  a[6];Vector C = Vector(0, 0);for(int i = 0; i < 6; i ++){   C += V[i];}C /= 6.0f;for(int i = 0; i < 6; i ++){    Vector D = V[i] - C;    a[i] = atan2(D.y, D.x);}// sort angles and corresponding vertices by ascending order, that will give you the list of vertices in anti-clockwise order.


Everything is better with Metal.

This topic is closed to new replies.

Advertisement