pyblenderSDIC.meshes.TriangleMesh3D.compute_triangle_areas#
- TriangleMesh3D.compute_triangle_areas() None [source]#
Compute the areas of the triangles in the mesh.
The areas are computed using the cross product of the edges of each triangle. The result is stored in the
triangle_areas
attribute as a NumPy array of shape (M,), where M is the number of triangles and each triangle contains the area of a triangle.\[A = \frac{\| (P_2 - P_1) \times (P_3 - P_1) \|}{2}\]where \(P_1\), \(P_2\), and \(P_3\) are the vertices of the triangle, \(\times\) is the cross product, and \(\| \cdot \|\) is the norm.
from pyblenderSDIC.mesh import TriangleMesh3D # Create a TriangleMesh3D instance mesh = TriangleMesh3D(vertices=..., triangles=...) # Compute the areas of the triangles mesh.compute_triangle_areas() # The areas are now available in the `triangle_areas` attribute mesh.triangle_areas