[Math] Finding the counter-clockwise direction of points in 3d

3dgeometrypolygons

I have a set of 5 points of a polygon in 3d. I want to order these points in a counter-clockwise direction. How do I do this?

In 2d, to check if two points are ordered counter-clockwise or clockwise, you compute the area (with the origin as (0,0)) $\frac{1}{2}ab$, and if the sign is +ve then the two points are ordered counter-clockwise, and vice-versa.

In 3d, you can compute $\frac{1}{2}|a \times b|$, where $\times$ is the cross product, and $|$ is the magnitude, and therefore this will always return a positive number.

Ultimately, I want to compute the normal of a polygon.

Best Answer

Given 3 points $A, B, C$. Take the cross product $AB \times AC$. This gives you the normal vector to the plane. If this normal vector points to you, then $A, B, C$ is in a counter clockwise position. You can check if this vector is pointing away from or towards you by taking the dot product of that vector and the vector in the direction you are viewing.