An algorithm to find the well oriented normal of a polygon

250 Views Asked by At

I have polygons in 3D which are supposed to be each planar and each coded as a vector of the vertices they are composed of. Polygons can be convex or concave but have no holes.

In these vectors, the vertices are ordered so that they counterclockwise trace the perimeter of the polygon in the right order.

To determinate the normal of a polygon, I have coded the algorithm below.

Is this algorithm mathematically correct? Is there a more efficient one?

A polygon vector is [V0, ...., Vp].

For each n in [1, p-1], calculate Nn = cross product of (V0,Vn) and (V0, Vn+1).

Make the sum S of all Nn.

S give the wanted orientation (or -S depending on a convention).