# Ordering vertices in counter-clockwise manner in 3D space.

This is my first question in math and if I cannot get it right for the first time, please forgive me. I'm working on a simulation and I need to order vertices of a triangle in counter-clockwise manner.

I'm reading these vertices from an STL file, which provides the three vertices and pre-calculated normals of the triangles that define an object. IOW, I have triangulation data for a 3D solid.

I can do the ordering with calculating the normal of the triangle using the vertices and trying to equalize the signs of the normal vector with the provided one in the file.

I wonder whether there's another way to find the correct order using nothing but the vertices.

If you know from the start that the triangles form a triangulation of an orientable surface (i.e. any two triangles are either disjoint, have a vertex in common, or have an edge in common, and the triangles having a given vertex in common share edges in a cyclic way) then you can pick one of the triangles, say $\Delta:=\{a,b,c\}$, and orient it at will. By orienting I mean that one cyclic order, e.g., $a\to b\to c\to a$, of the vertices is declared positive, the other negative. Starting from this seed orient all other triangles coherently. This means the following: When two triangles $\Delta_1:=\{a,b,c\}$ and $\Delta_2:=\{a,b,d\}$ with $c\ne d$ share an edge $\{a,b\}$ then the orientation of this edge in $\Delta_1$ should be opposite to its orientation in $\Delta_2$.