Physics · interface

MassProperties

A shape's volume, centre of mass and inertia tensor, at a given density.

Explained in Your first game, Rigid bodies.

interface MassProperties
import type { MassProperties } from '@driftengine/physics';

In depth

Exact for a hull, by tetrahedral decomposition over its face loops — which is why this sits immediately beside the loops themselves: one build-time addition to ConvexShape pays for both contact clipping and this, and neither is a separate piece of work.

A rounded hull — radius > 0 with faces — is the Minkowski sum of a hull and a ball, which has no closed form. Sphere and capsule are handled by the ball case below; anything else with a radius is approximated by the hull's tensor about the same centre. What that gives up is accuracy for a heavily rounded hull, where the shell is a large fraction of the volume. What would make it wrong is a consumer building such a shape and caring how it tumbles, at which point the answer is a numerical integration over the support function rather than a fudge factor.

Build-time only, like everything else in shape.ts: nothing here may be called per tick.

Properties

NameTypeDescription
volumenumber
comXnumber
comYnumber
comZnumber
ixxnumberThe tensor about the centre of mass. Six independent terms, symmetric.
iyynumber
izznumber
ixynumber
ixznumber
iyznumber