Function second_moments

pub fn second_moments<M>(
    mesh: &M,
    tolerance: Tolerance,
) -> Result<DVec3, MeshMeasureError>
where M: TriangleMeshView + ?Sized,
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.

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.