I am trying to do some calculations taking into account the orientations and translations of some rigid bodies. I have two right-handed coordinate systems that are rotated arbitrarily with respect to one another. I want to transform to the local coordinate system for the center of mass and then do the back transform to verify that everything is set up correctly. When I do the back transform, I correctly recover the original center-of-mass position in x, but not in y or z. What am I misunderstanding?

Let $\vec{e}_{X}$, $\vec{e}_{Y}$, $\vec{e}_{Z}$ be the unit vectors for the axes of the first system, the global system that has (1,0,0), (0,1,0), (0,0,1) as a basis, and $\vec{e}_{1}$, $\vec{e}_{2}$, $\vec{e}_{3}$ the unit vectors for the axes of the local system. Let $\vec{A}$ be any vector in the two frames of reference. By definition:

$$\vec{A}=A_{X}\vec{e}_{X}+A_{Y}\vec{e}_{Y}+A_{Z}\vec{e}_{Z}$$ $$\vec{A}=A_{1}\vec{e}_{1}+A_{2}\vec{e}_{2}+A_{3}\vec{e}_{3}$$

I do the coordinate transformation from the global to the local system, taking into account both orientations and translations, by:

$$A_{1} = \vec{e}_{1} \cdot \vec{A} + A_{X} = (\vec{e}_{1} \cdot \vec{e}_{X})A_{X} + (\vec{e}_{1} \cdot \vec{e}_{Y})A_{Y} + (\vec{e}_{1} \cdot \vec{e}_{Z})A_{Z} + A_{X}$$ $$A_{2} = \vec{e}_{2} \cdot \vec{A} + A_{Y} = (\vec{e}_{2} \cdot \vec{e}_{X})A_{X} + (\vec{e}_{2} \cdot \vec{e}_{Y})A_{Y} + (\vec{e}_{2} \cdot \vec{e}_{Z})A_{Z} + A_{Y}$$ $$A_{3} = \vec{e}_{3} \cdot \vec{A} + A_{Z} = (\vec{e}_{3} \cdot \vec{e}_{X})A_{X} + (\vec{e}_{3} \cdot \vec{e}_{Y})A_{Y} + (\vec{e}_{3} \cdot \vec{e}_{Z})A_{Z} + A_{Z}$$

which reduces to

$$A_{1} = e_{1,X} A_{X} + e_{1,Y} A_{Y} + e_{1,Z} A_{Z} + A_{X}$$ $$A_{2} = e_{2,X} A_{X} + e_{2,Y} A_{Y} + e_{2,Z} A_{Z} + A_{Y}$$ $$A_{3} = e_{3,X} A_{X} + e_{3,Y} A_{Y} + e_{3,Z} A_{Z} + A_{Z}$$

where $A_{X}$, $A_{Y}$, $A_{Z}$ are the coordinates of the center of mass in the global system. Then, I do the back transform:

$$A_{X} = e_{1,X} A_{1} + e_{2,X} A_{2} + e_{3,X} A_{3} - e_{1,X} A_{X} - e_{2,X} A_{Y} - e_{3,X} A_{Z}$$ $$A_{Y} = e_{1,Y} A_{1} + e_{2,Y} A_{2} + e_{3,Y} A_{3} - e_{1,Y} A_{X} - e_{2,Y} A_{Y} - e_{3,Y} A_{Z}$$ $$A_{Z} = e_{1,Z} A_{1} + e_{2,Z} A_{2} + e_{3,Z} A_{3} - e_{1,Z} A_{X} - e_{2,Z} A_{Y} - e_{3,Z} A_{Z}$$

Again, I am only able to recover the x-coordinate of the center of mass, but not the y- or z-coordinate. What am I misunderstanding?

  • $\begingroup$ Can you please define $A_{1,2,3},A_{X,Y,Z},\vec{A}$ ? $\endgroup$
    – user619894
    Commented Apr 27, 2020 at 9:08
  • $\begingroup$ @user619894 Done. Thanks for pointing that out. I hope it's clearer now. $\endgroup$
    – user95199
    Commented Apr 27, 2020 at 13:11

1 Answer 1


Part of the problem is that you’re using $A_X$, $A_Y$ and $A_Z$ to mean two different things. Toward the top, you say that they are the coordinates of an arbitrary point, but later you say that they’re the global coordinates of the center of mass, and you mix both of these meanings in the same mathematical expressions. The more fundamental problem is that you’ve gotten the transformations backwards. One can see that something’s not right even before inverting the transformation since the expressions for the local coordinates don’t reduce to $0$ for the center of mass, which supposedly is the origin of the local frame.

I’m going to use a different notation from yours so that essential features don’t get lost in a mass of algebra. Let $\overline{\mathbf p}$ be the global coordinates of the center of mass and $\mathbf p$ the global coordinates of an arbitrary point. The transformation to the local (center-of-mass) frame will have the form $$\mathbf p'=R(\mathbf p-\overline{\mathbf p})\tag1$$ where $R$ is a rotation matrix that we’ll come back to later. Note that we first translate the origin to the center of mass by subtracting the global coordinates of the new origin and then rotate the result, which is essentially the inverse of what you have. The center of mass should be the origin of the new coordinate system, and (1) obviously produces the zero vector when you set $\mathbf p=\overline{\mathbf p}$.

The inverse map is then $$\mathbf p = R^{-1}\mathbf p'+\overline{\mathbf p}.\tag2$$ The center of mass is the origin of the local frame, and substituting $\mathbf 0$ for $\mathbf p'$ in (2) recovers $\overline{\mathbf p}$ as expected.

Now, what does the rotation $R$ look like? We can write it as the product of a matrix that maps from the global coordinate system to the standard basis (in your application those are one and the same, but I’ll develop it for any pair of bases) and one that maps from the standard basis to the new one. The columns of a change-of-basis matrix are the coordinates of the old basis expressed in the new basis, so the combined change-of-basis matrix is $$\begin{bmatrix}\mathbf e_1&\mathbf e_2&\mathbf e_3\end{bmatrix}^{-1} \begin{bmatrix}\mathbf e_X&\mathbf e_Y&\mathbf e_Z\end{bmatrix}.\tag3$$ All of the $\mathbf e$’s in this expression are the coordinates of the various basis vectors expressed relative to the standard basis. Note that the left-hand matrix is inverted since going from the standard basis to the second basis is the inverse of going from the second basis to the standard basis. Since both of your bases are orthonormal, these matrices are orthogonal, so (3) becomes \begin{align} \begin{bmatrix}\mathbf e_1&\mathbf e_2&\mathbf e_3\end{bmatrix}^T \begin{bmatrix}\mathbf e_X&\mathbf e_Y&\mathbf e_Z\end{bmatrix} &= \begin{bmatrix}\mathbf e_1^T\\\mathbf e_2^T\\\mathbf e_3^T\end{bmatrix} \begin{bmatrix}\mathbf e_X&\mathbf e_Y&\mathbf e_Z\end{bmatrix} \\ &= \begin{bmatrix} \mathbf e_1\cdot\mathbf e_X & \mathbf e_1\cdot\mathbf e_Y & \mathbf e_1\cdot\mathbf e_Z \\ \mathbf e_2\cdot\mathbf e_X & \mathbf e_2\cdot\mathbf e_Y & \mathbf e_2\cdot\mathbf e_Z \\ \mathbf e_3\cdot\mathbf e_X & \mathbf e_3\cdot\mathbf e_Y & \mathbf e_3\cdot\mathbf e_Z \end{bmatrix}, \end{align} i.e., the elements of $R$ are the pairwise dot products of the basis vectors. Since this matrix is itself orthogonal, its inverse is also equal to its transpose. In your case, the first basis is just the standard basis, so the right-hand matrix in these products is the identity, and the change-of-basis matrix is simply $[\mathbf e_1\;\mathbf e_2\;\mathbf e_3]^T$, i.e., $$R = \begin{bmatrix}e_{1,X}&e_{1,Y}&e_{1,Z}\\e_{2,X}&e_{2,Y}&e_{2,Z}\\e_{3,X}&e_{3,Y}&e_{3,Z}\end{bmatrix}.$$ This matrix is also orthogonal, so $R^{-1}=R^T$.

  • $\begingroup$ Thank you! Very clear explanation. I appreciate it. $\endgroup$
    – user95199
    Commented Apr 28, 2020 at 3:03

You must log in to answer this question.