Documentation
    Preparing search index...

    Function toPrincipalInertia3d

    • Reduces §23's inertiaTensor to the principal moments Rapier 3D wants, and rejects anything it cannot represent exactly.

      §23 hands the adapter a full Matrix3. Rapier's 3D mass API takes a principal inertia vector plus an angularInertiaLocalFrame rotation — that is, the tensor already diagonalized, with the frame naming the axes it was diagonalized in. Turning an arbitrary symmetric tensor into that pair is an eigendecomposition.

      This adapter accepts diagonal tensors only and throws on any non-zero product of inertia (decision, WP-5.5). The reasoning:

      • A diagonal tensor is already expressed in its principal axes, so the mapping is exact and the frame is the identity. Nothing is approximated and nothing is silently discarded.
      • A Jacobi eigendecomposition would introduce an iterative float computation into a path that feeds the solver, along with arbitrary eigenvector ordering and sign conventions — all of it in JavaScript Math, i.e. outside the deterministic wasm (§33). Getting that subtly wrong would produce a body that spins plausibly but incorrectly, which is the exact failure mode §85 exists to prevent.
      • Dropping the off-diagonal terms and keeping the diagonal would be wrong and quiet: the diagonal of a non-diagonal tensor is not its principal moments.

      The honest minimal answer, matching P5-6's minimalism, is therefore to implement the exact case and refuse the rest with an error that says what to do. A later packet may add a decomposition; widening an accepted input set is backward compatible.

      Parameters

      Returns RapierVector3