Expand description
Mass properties of closed triangle meshes and their combination.
computeintegrates aMesh(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::bodyapplies a density and a length unit and gives aBodyin SI units;combineadds bodies by the parallel axis theorem andBody::inertia_aboutshifts 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§
- Length
Unit - 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).