Find a Guide

Rotation/Directional Cosine Matrices

Introduction

Let's there is vector in a coordinate system, but we want to rotate to a new reference frame. Is this possible? Can we do this more than once? The short answer is yes!

When we rotate about an axis, we use what is called a rotation matrix; another name for a rotation matrix is a directional cosine matrix. There are 3, one for each axis, x, y, and z. We can use either one of them to rotate to a new reference frame, or we can use multiple rotation matrices to rotate about multiple axes. Let's dive in to learn how to derive one of these rotation matrices!

Deriving 2D Matrix

We will start off by learning how to derive the counterclockwise z rotation matrix, which is a rotation of the xy plane.

This image shows a rotation in the xy plane.

Fig. 1 - Vector rotation in the xy plane.

In Figure 1, we start off with the un-rotated xy axes. Then they are rotated by an angle $ -\theta $ such that we get the new axis X and Y. What we can do is separate X and Y into their x and y components to get

$$ X = x \cos( -\theta ) - y \sin( -\theta ) $$
$$ Y = x \sin( -\theta ) + y \cos( -\theta ) $$

This can then be combined into matrix form to obtain the 2D rotation matrix for the xy plane.

[ 1 ]

$$ \begin{Bmatrix} X \\ Y \end{Bmatrix} = \begin{bmatrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end{bmatrix} \begin{Bmatrix} x \\ y \end{Bmatrix} $$

Notice that since $ \theta $ was a clockwise rotation, it was negative. As for $ \cos( -\theta ) $, cosine is symmetric, so $ \cos( -\theta ) = \cos( \theta ) $. However, for $ \sin( -\theta ) $, sin is not symmetric, so $ \sin( -\theta ) = -\sin( \theta ) $. Now the full 2D counterclockwise rotation matrix about z, $ R_{z,2D} $, can be written as

[ 2 ]

$$ R_{z,2D} = \begin{bmatrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end{bmatrix} $$

3D Matrices

This same process can be extended to get the 3D counterclockwise rotation matrices about each axis.

[ 3 ]

$$ R_x = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos \theta & \sin \theta \\ 0 & -\sin \theta & \cos \theta \\ \end{bmatrix} $$
$$ R_y = \begin{bmatrix} \cos \theta & 0 & -\sin \theta \\ 0 & 1 & 0 \\ \sin \theta & 0 & \cos \theta \\ \end{bmatrix} $$
$$ R_z = \begin{bmatrix} \cos \theta & \sin \theta & 0 \\ -\sin \theta & \cos \theta & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} $$

These are the 3D rotational matrices and they come in handy for many different applications, especially in aircraft coordinate system changes. For example, in flight dynamics, there are sequences of rotation that are used for planes. In the Flight Vehicle Dynamics guide, the commonly used sequence is 3-2-1 which means a rotation about the z-axis, followed by a rotation about the y-axis, and then a rotation about the x-axis, where 3 corresponds to z, 2 to y, and 1 to x.

MATLAB Code

Below are some handy functions for quickly calculating rotation matrices and combinations of rotation matrices.

matlab

rotx.m

matlab

roty.m

matlab

rotz.m

matlab

CDCM.m

Find a Guide