pub fn second_moments<M: TriangleMeshView + ?Sized>(
mesh: &M,
tolerance: Tolerance,
) -> Result<Vec3, MeshMeasureError>Expand description
Second moments of the enclosed solid about the origin.
The x, y, z components are the integrals of x^2, y^2 and
z^2 over the enclosed volume, i.e. the diagonal of the second-moment
tensor for unit density. The classical inertia tensor diagonal is
(Iyy + Izz, Ixx + Izz, Ixx + Iyy) from these, so callers can derive
either convention without the provider guessing which one they meant.
§Method
The divergence theorem again, one order higher than the volume sum:
for a closed oriented triangulation the integral of x^2 over the
enclosed region reduces to a sum over triangles of terms in the
vertices’ coordinates. Each triangle contributes
(nx / 60) * sum over the 10 symmetric monomials, the standard
closed-form tetrahedral moment about the origin.
The sum runs about the mesh’s first vertex, as volume_properties’s
does, and is shifted back to the origin by the parallel-axis terms: with
x = x' + o, int x_i^2 = int x'_i^2 + 2 o_i int x'_i + o_i^2 V
(#343). About the world origin each term grew with the fifth power of
the distance to it, and a box on a national grid lost its central
moments entirely to the cancellation.
Requires the same closed two-manifold input as volume_properties:
an open shell has no enclosed region and the integral is meaningless,
so it is refused rather than summed into a plausible number.