问题
If all nodes of a polyhedron (may be non-convex) and their coordinates are known, the points of a face are given in order (anti-clockwise or clockwise around the outward normal), how do I obtain the outward normal vector of each face?
Here is a method for convex polyhedron: Computing face normals and winding
How about a general polyhedron that could be non-convex?
回答1:
Here is one method. Fix the orientation of one face F0 of your polyhedron P. You don't yet know if this is counterclockwise from the outside, so that the right-hand-rule gives an outward pointing normal from the cross product.
Now orient an adjacent face F1 to be compatible with F0's orientation, in that the shared edge is oriented → in F0 and ← in F1. Continue propagating the orientations of faces until every face of P is consistent with F0. So now all normals either point inward or all point outward.
Now compute the volume of P by summing signed tetrahedra volumes. The volume will be positive if all faces are oriented counterclockwise, and negative if all clockwise. If it comes out negative, reverse all face orientations.
Computing the signed volume is all over the web, including here: Computational Geometry in C.
来源:https://stackoverflow.com/questions/48093451/calculating-outward-normal-of-a-non-convex-polyhedral