pyblenderSDIC.meshes.TriangleMesh3D.compute_triangle_centroids#

TriangleMesh3D.compute_triangle_centroids() None[source]#

Compute the centroids of the triangles in the mesh.

The centroids are computed as the average of the vertices of each triangle. The result is stored in the triangle_centroids attribute as a NumPy array of shape (M, 3), where M is the number of triangles and each row contains the centroid coordinates of a triangle.

\[C = \frac{P_1 + P_2 + P_3}{3}\]

where \(P_1\), \(P_2\), and \(P_3\) are the vertices of the triangle.

from pyblenderSDIC.mesh import TriangleMesh3D

# Create a TriangleMesh3D instance
mesh = TriangleMesh3D(vertices=..., triangles=...)

# Compute the centroids of the triangles
mesh.compute_triangle_centroids()

# The centroids are now available in the `triangle_centroids` attribute
mesh.triangle_centroids