# Sign independency when rotating an inertia tensor with a rotation matrix

I have a set of points that represent a rigid cylinder for which I calculate its rotation in space (x,y,z) using the formula

$$\mathbf{J} = \mathbf{R^T} \mathbf{J_0} \mathbf{R}$$

with R being the rotation matrix and $$J_0$$ the inertia tensor for local coordinates.

To get the rotation tensor I calculate the cross product of the normalized vector pointing in the cylinder's current orientation $$\mathbf{p}$$ and the unit vector $$\mathbf{p_0} = (0,1,0)^T$$ (matching $$J_0$$),

$$\mathbf{n} = \mathbf{p} \times \mathbf{p_0}$$

which leaves me with the orientation of the rotation axis $$\mathbf{n}$$ and the angle of rotation $$\varphi$$:

$$\mathbf{n} = (-p_z, 0, p_x)^T$$ and $$\sin(\varphi) = \sqrt{{p_x}^2 + {p_z}^2}$$

Using those information I can easily calculate my rotation matrix (see e.g. wiki -> rotation matrix).

Now I have the following problem: The cylinder points are stored in an unsorted array. When calculating the orientation vector I simply subtract the position of two random points in the cylinder and normalize the vector. Hence I do not know which direction my vector is pointing: it can be $$\mathbf{p}$$ or $$-\mathbf{p}$$. Pyhsically there should be no difference in the calculation of my inertia tensor due to the symmetry of a cylinder. But how do I prove it mathematically?

I tried writing down the rotation matrix and looked for symmetries/squares or other ways to get rid of the minuses, but could not find a way. I believe the solution lies in the first equation mentioned and the multiplication with the transposed rotation matrix. Someone already tried to explain it here (last comment), but it does not apply, if you only calculate the inertia tensor...

Maybe someone could explain why the multiplication with the transpose is necessary, what kind of rotation it represents and why (or if) it leads to the sign independency of the orientation tensor.

• "inertia tensor for cylinder coordinates" looks strange there. Do you actually mean "inertia tensor for the cylinder"? – Tobias Sep 20 at 11:29
• In the formula for $R$ at wikipedia: If the rotation axis $u$ changes sign then also the angle $\theta$ changes sign. All terms consisting of components of $u$ and $sin(\theta)$ are quadratic in $R$. So the choice of the orientation of the rotation axis is not relevant for the Rotation matrix of one and the same rotation. Note that your formula $\sin(\varphi)=\sqrt{p_x^2 + p_z^2}$ neglects the sign of the rotation angle. – Tobias Sep 20 at 11:37
• yes, basically. I wanted to specify that these are its body coordinates that align with the symmetry axes of the cylinder and not with the global coordinates (like $\mathbf{p}$). But maybe that just made it more complicated ... – BlueFire Sep 20 at 11:44
• The problem is that cylinder coordinates does mean something else. Better are: "local coordinates" (it is most often self-understood which local coordinates are meant), "coordinates aligned with the cylinder axes", "body frame coordinates", or just "body system". – Tobias Sep 20 at 11:50
• good point, I corrected it now. I did not think of the ambiguity there, thanks! – BlueFire Sep 20 at 12:03

considering the values of $$\mathbf{n}$$ the rotation matrix can be simplified to $$R = \left(\begin{matrix} p_z^2&-p_z \sqrt{p_x^2 + p_z^2}&p_xp_z\\ p_z\sqrt{p_x^2+p_z^2}&0&-p_x\sqrt{p_x^2 + p_z^2}\\ p_zp_x&p_x\sqrt{p_x^2 + p_z^2}&p_z^2 \end{matrix}\right)$$
Then the matrix can product $$\mathbf{J} = \mathbf{R^T} \mathbf{J_0} \mathbf{R}$$ can be solved and it becomes apparent, that every component of the matrix is dependent on squares of $$p_i$$, thus making it independent of the orientation vector's sign.
The multiplication of the inertia tensor with the rotation matrix's transpose is necessary when rotating a matrix (like $$\mathbf{J_0}$$). When rotating a vector $$\mathbf{a_0}$$ it is sufficient to calculate
$$\mathbf{a} = \mathbf{R} \mathbf{a_0}$$