Positive second-moment matrix test for an inertia tensor (source code)

= Positive second-moment matrix test for an inertia tensor
{title2=$\mathsf S=\tfrac12\operatorname{tr}(\mathsf I)\mathsf 1-\mathsf I\succeq0$}

For a nonnegative <mass distribution> relative to an origin, the second-moment matrix is $\mathsf S=\int\mathbf r\mathbf r^{\mathsf T}\,dm$ and the <inertia tensor> is $\mathsf I=\operatorname{tr}(\mathsf S)\mathsf 1-\mathsf S$. Taking the trace gives the displayed inverse formula, which must be <positive semidefinite>. Conversely, any such $\mathsf S$ can be realized by pairs of point masses along its orthogonal principal directions. Thus this is also a realizability test when total mass and dimensions are unrestricted. In principal coordinates it is equivalent to the <moment-of-inertia triangle inequalities>: $I_2+I_3-I_1=2S_{11}\ge0$, with cyclic counterparts. A symmetric positive definite matrix alone need not be a physical <inertia tensor>.