Skip to main content

Module mass

Module mass 

Source
Expand description

Mass properties: how much there is, where its centre is, and how it resists being spun.

Three measures, one for each dimension a shape can have (the length of its edges, the area of its faces, the volume it encloses), each with the centre of that measure and the inertia tensor about that centre.

§Integrated on the surfaces where possible, meshed where not

Area and volume are integrated on the exact surfaces first. A face on a plane, cylinder, cone, sphere or torus bounded by a chart rectangle or a full circle has a closed form; any other face with pcurves is integrated round its chart boundary by Green’s theorem. Either way the result reports a deflection of zero.

A shape with a face neither can take (no pcurves, a scaling placement, a boundary that does not close in the chart) is measured on its tessellation instead, and the result carries the deflection it was computed at. Halving the deflection and seeing the answer move tells a caller how much to trust it; MassProperties::deflection is what makes that check possible. Lengths are always measured on a discretization.

§The one formula

Length, area and volume all reduce to summing over simplices (segments, triangles, tetrahedra), and the second moment of a simplex has the same shape in every dimension:

∫ x_i x_j  =  m / (n(n+1)) · [ Σ_k p_k p_kᵀ + (Σ_k p_k)(Σ_k p_k)ᵀ ]

for n vertices and measure m. Barycentric integration gives it: the integral of λ_a λ_b over a simplex is m·d!·(1+δ_ab)/(d+2)!, and n(n+1) is what that collapses to. One function serves all three, which is also why the three agree with each other rather than drifting apart.

Structs§

MassProperties
How much of something there is, and how it is distributed.

Functions§

linear_properties
The length of a shape’s edges, and how it is distributed.
surface_properties
The area of a shape’s faces, and how it is distributed.
volume_properties
The volume a shape encloses, and how it is distributed.