Skip to main content

Module massprops

Module massprops 

Source
Expand description

Mass properties of closed triangle meshes and their combination.

  • compute integrates a Mesh (the cached 3D preview of a file): volume, centroid and the inertia tensor about the centroid per unit density, in model units (Eberly, Polyhedral Mass Properties (Revisited); the divergence theorem turns the volume integrals of 1, x, y, z, x², y², z², xy, yz, zx into exact sums over the triangles). The integrals are taken relative to the centre of the bounding box, so a thin part far from the origin (a vehicle frame) keeps its digits.
  • An edge check counts open, non-manifold and inconsistently oriented edges (vertices welded on a grid, like the shape signatures); a fully inverted mesh (negative volume) is flipped and reported.
  • Geometry::body applies a density and a length unit and gives a Body in SI units; combine adds bodies by the parallel axis theorem and Body::inertia_about shifts the tensor to any point.

Conventions: right-handed axes of the file (the common vehicle frame); the inertia tensor is stored in tensor form – the off-diagonal entries are the negative products of inertia (ixy = −∫ xy dm).

Untrusted input: the server runs compute in the isolated preview process (see preview); the function itself is bounded (one pass over the triangles plus a sort of the edges, the edge check stops at EDGE_CHECK_LIMIT) and returns errors, never panics.

Structs§

Body
A rigid body in SI units: mass (kg), centre of gravity (m) and inertia tensor about the CG (kg·m², tensor form).
Geometry
The geometry of one mesh, per unit density in model units.

Enums§

LengthUnit
Length units of mesh files and their size in metres.
Outcome
What the preview process writes: the geometry or why there is none.

Constants§

EDGE_CHECK_LIMIT
Larger meshes get no edge check (their closedness is then unknown).
VERSION
Bump when the computation changes: cached results of another version are ignored and computed again (the cache file name carries it).

Functions§

combine
Adds bodies by the parallel axis theorem: total mass, common CG and the tensor about it. Bodies without mass are skipped; no mass at all gives the empty body (mass 0 at the origin).
compute
Mass properties of a triangle mesh (per unit density, model units). Point clouds, meshes without volume and broken coordinates are errors.
principal_moments
Principal moments of a tensor, largest first (cyclic Jacobi).

Type Aliases§

Sym
Symmetric 3×3 tensor [xx, yy, zz, xy, yz, xz].
V3