In this post, we explain:
- How to derive rotation matrices
- How to transform vectors between two rotated coordinate systems.
A YouTube video accompanying this post is given below.
Rotation matrices are important for modeling robotic systems and for solving a number of problems in robotics.
Consider Fig. 1 below.
![](https://aleksandarhaber.com/wp-content/uploads/2022/01/graph1-968x1024.png)
![Rendered by QuickLaTeX.com \theta](https://aleksandarhaber.com/wp-content/ql-cache/quicklatex.com-356a08e839ab6974a16448e16e56745d_l3.png)
![Rendered by QuickLaTeX.com z_{0}](https://aleksandarhaber.com/wp-content/ql-cache/quicklatex.com-c6b4c2ff9208eb30adfcab5efe255cf2_l3.png)
We have two coordinate systems. The coordinate system is fixed. This coordinate system is called the inertial or reference coordinate system. Note that in robotics, coordinate systems are also called frames. The coordinate system
is rotated for the angle
with respect to the coordinate system
around the
axis. The vectors
,
, and
are the unit vectors of the coordinate axes
,
, and
. On the other hand, the vectors
,
, and
are the unit vectors of the coordinate axes
,
, and
.
Consider the vector that rotates together with the frame
and that is fixed with respect to this frame. This vector is shown in the figure below.
![](https://aleksandarhaber.com/wp-content/uploads/2022/01/graph2.png)
![Rendered by QuickLaTeX.com p](https://aleksandarhaber.com/wp-content/ql-cache/quicklatex.com-3bf85f1087e9fbed3a319341134ac1a2_l3.png)
![Rendered by QuickLaTeX.com X_{1}Y_{1}Z_{1}](https://aleksandarhaber.com/wp-content/ql-cache/quicklatex.com-5f1acba3190b57e00c2af5c0a19721dd_l3.png)
Problem: Knowing the coordinates of the vector in the frame
, and the angle of rotation
, represent this vector in the frame
.
The representation of the vector in the frame
is
(1)
where the notation stands for the representation of the vector
in the frame
. And the scalars
,
, and
are the projections. We want to compute this representation of the vector
in the frame
(2)
(3)
where the notation is used to denote the scalar product between vectors. The last equation can be represented in the vector form
(4)
where
(5)
is the rotation matrix. The notation denotes the transformation from the frame
(subscript) to the frame
(superscript). The first column of the rotation matrix is the projection of the vector
onto the axes of the frame
. The second column of the rotation matrix is the projection of the vector
onto the axes of the frame
. The third column of the rotation matrix is the projection of the vector
onto the axes of the frame
.
Now, consider Fig.1 again. Since and
are the unit vectors, we have
. That is,
is the projection of the vector
onto the vector
, and
is the angle between these two vectors. By using this method, we can populate the rotation matrix as follows:
(6)
Rotation matrices have the following nice property:
(7)
That is, they are orthonormal. The inverse of is actually a transformation from the frame
to the frame
, to see this, multiply the equation (4) by
:
(8)
That is, .