pyblenderSDIC.meshes.TriangleMesh3D.compute_triangle_normals#
- TriangleMesh3D.compute_triangle_normals() None [source]#
Compute the normals of the triangles in the mesh.
The normals are computed as the cross product of the edges of each triangle. The result is stored in the
triangle_normals
attribute as a NumPy array of shape (M, 3), where M is the number of triangles and each row contains the normal vector of a triangle.The normals are normalized to have unit length.
\[N = \frac{(P_2 - P_1) \times (P_3 - P_1)}{\| (P_2 - P_1) \times (P_3 - P_1) \|}\]where \(P_1\), \(P_2\), and \(P_3\) are the vertices of the triangle, and \(\times\) is the cross product.
from pyblenderSDIC.mesh import TriangleMesh3D # Create a TriangleMesh3D instance mesh = TriangleMesh3D(vertices=..., triangles=...) # Compute the normals of the triangles mesh.compute_triangle_normals() # The normals are now available in the `triangle_normals` attribute mesh.triangle_normals