# Rotation matrix from an inertia tensor

I have a set of weighted points in 3D space (in fact, a molecule) and I'm trying to align the principal axes of this set with the $x$, and $y$ and $z$ axes. To do so, I've first translated my points so their barycenter coincides with the origin. Then, I've calculated the moment of inertia tensor $I$ and its eigenvalues ($\lambda_i$) and eigenvectors ($V_i$).

Then, I need to build the rotation matrix associated with the rotation bringing my vectors $V_i$ onto $(x,y,z)$. I assumed that would be the inverse of the matrix formed by the vectors $V_i$ in columns, but it is not. So, how would you write this matrix from what I have already calculated?

-

We have $I V_i = \lambda_i V_i$, where $\lambda_i$ is real. Let $M$ be the matrix whose columns are the normalized eigenvectors of $I$. Then $M$ is orthogonal, $M^T M = M M^T = \mathbb{I}$. Thus, $M^T I M = D = \mathrm{diag}(\lambda_1,\lambda_2,\lambda_3)$ and $M^T M_i = e_i$. Notice that the last equation implies, for example, that $M^T M_1 = e_1 = (1\ 0\ 0)^T$. That is, the transpose of $M$ brings the principal axes to the Cartesian axes.

The simplest way to remember how the various objects transform is to look at the kinetic energy, for example, $$\begin{eqnarray*} \frac{1}{2}\omega^T I \omega &=& \frac{1}{2}\underbrace{\omega^T M}_{\xi^T} \underbrace{M^T I M}_D \underbrace{M^T \omega}_\xi \\ &=& \frac{1}{2} \sum_{i=1}^3 \lambda_i\xi_i^2, \end{eqnarray*}$$ where $\omega$ is the angular velocity in the original frame and $\xi$ is the angular velocity with respect to the principal axes.

If you are using Mathematica, note that the rows of the matrix it spits out are the unnormalized eigenvectors. In another computing environment the convention may be something else, so be careful. Without more information it is impossible to tell where this goes wrong for you.

-
I don't understand… Are you saying M is the rotation matrix bringing the principal axes to the cartesian axes? Because it doesn't work… and I've tried more than once! PS: My eigenvectors are already normalized. PPS: I don't know what you define as $\omega$ or $\xi$ or $D$ – F'x May 14 '12 at 20:59
@F'x: I added some clarification. If this doesn't help I'll need to see your code or computations to go further. – user26872 May 14 '12 at 22:10

I know that this this post is really old, but I was just working on the exact same problem, and I thought that maybe at some point in the future someone else might be facing the same issue as well.

I'm writing an algorithm for which I need to compare molecular structures, represented as sets of points in space, and I need these structures to be oriented in exactly the same way so that I can see if the coordinates for each point are the same, and with that if the structures are the same.

I tried the method with multiplying by the transpose of the eigenvector matrix of the inertia tensor. It's correct, the transpose of the matrix containing the eigenvectors orients the molecule properly when applied to it, and the same can be achieved with rotation matrices. With rotation matrices, I could align the inertia tensor that corresponds to the axis of maximum rotation symmetry with the z-axis, by rotating the molecule first around the x- axis to bring it in to the xz plane and then around the y- axis, to bring it at the same position as the z-axis of the cartesian coordinate system, and that works just fine.

But, I found that when this method is used, the resultant orientation doesn't discriminate between the relative directions in space, so the choice of the x- and y- axes is arbitrary, as well as the + and - directions on each axis. I think that maybe that's why the OP had the impression that it doesn't work.

The way that I solved this is by just going through the different choices of the eigenvector directions for the x- and y- axes as well as the + and - directions, which means that for every structure I have to do the checking many times, but for my system it was OK, because it's quite small. I think that for a small system this is a better solution, or perhaps it is possible to also specify the other two eigenvectors to correspond with either the x- or the y- axis, in which case the orientation would be absolute.

Anyway, this is a much simpler approach than any other method avialable.

But, since I am not a mathematician, I'm a chemist, I would like to ask, if my observation that when the transpose of the eigenvector matrix is applied, or when one eigenvector is fixed to be aligned with the z-matrix, the resultant orientation doesn't completely distinguish between the relative directions in space, is correct. And also, if this is correct, would aligning the other two eigenvectors with the x- and y- axes respectively fix this problem? And also, if this is correct, why is this? Is it related to some property of eigenvectors, or to some property of the inertia tensor, or of the inertia eigenvectors, or does it come from some property of matrix multiplication?

If anyone is using this method, I would recommend the diagonalization subroutines available in Lapack for Fortran, rather than Mathematica. The result is always an orthonormal matrix, and calculations are very straightforward.

-
Hi, I'm a chemist too. What you said is right, remember that if $v$ is an eigenvector of $R$, and the corresponding eigenvalue is $\lambda$: $R v = \lambda v$, but it is true for any $v' = \alpha v$ where $\alpha$ is a scalar. Notice what will happend if $\alpha = -1$... If $M_1$ and $M_2$ are the $N\times 3$ cartesian matrixes of two molecules, I think that a better solution is to find the rotation matrix that best" overlap $R M_1$ and $M_2$. But this method is only suitable when you have paired atoms (when you know exactly a the bijection between atoms in booth molecules). – user1420303 Sep 2 at 23:21