Homogeneous transformation matrix (5)

Kinematics & Universal Numerics
July 22, 2019

The axis-angle representation.

In this blog we will introduce the second parametrization of a 3D rotation matrix. The idea is that any 3D rotation can be obtained by rotating the original coordinate system with respect to some axis by some angle $\theta$.

We should first note that this is still a parametrization of three degrees of freedom: an angle $\theta$ has one degree of freedom; an axis is equivalent to a normal vector ${\mathbf{d}}$, which can be parametrized by two angles $(\phi,\,\psi)$:

 $\displaystyle{\mathbf{d}}=\begin{bmatrix}d_{x}\\ d_{y}\\ d_{z}\end{bmatrix}=\begin{bmatrix}s_{\phi}c_{\psi}\\ s_{\phi}s_{\psi}\\ c_{\phi}\end{bmatrix}.$ (1)

Such a parametrization is not unique when $d_{z}=1$ and $\phi=0$, or $d_{z}=-1$ and $\phi=\pi$. Then $s_{\phi}=d_{x}=d_{y}=0$, so $\theta$ is arbitrary. Otherwise, if $|d_{z}|<1$, then we have

 $\displaystyle\left\{\begin{array}[]{ll}\phi=\text{atan2}(\sqrt{1-d_{z}^{2}},\ % d_{z})&\in(0,\pi)\\ \psi=\text{atan2}(d_{y},d_{x})&\in(-\pi,\pi].\end{array}\right.$ (2)

Imagine we can do some rotation ${\mathbf{S}}$ such that the $z$-axis aligns with the vector ${\mathbf{d}}$. Then we rotate around the new $z$-axis by angle $\theta$. Lastly we revert the first rotation by performing the inverse rotation of ${\mathbf{S}}$, which is the rotation ${\mathbf{S}}^{T}$. We shall prove the correctness of this approach, but for now let’s write the overall rotation as

 $\displaystyle{\mathbf{R}}={\mathbf{S}}\cdot\text{Rot}_{z}({\theta})\cdot{% \mathbf{S}}^{T}.$ (3)

To transform from the original coordinate system to the destination coordinate system, we read (3) from left to right as follows.

1. Step 1.

From the original coordinate system, perform some rotation ${\mathbf{S}}$ such that ${\mathbf{d}}$ is the $z$-axis.

2. Step 2.

Rotate about the new $z$-axis by angle $\theta$—this rotation is $\text{Rot}_{z}({\theta})$.

3. Step 3.

Perform the rotation ${\mathbf{S}}^{T}$, the inverse of the rotation in Step 1.

Since ${\mathbf{S}}$ is the first rotation making the $z$-axis in Step 2 align with ${\mathbf{d}}$, the last column ${\mathbf{S}}$ is exactly ${\mathbf{d}}$. That is,

 $\displaystyle{\mathbf{S}}{\mathbf{e}}_{1,3}={\mathbf{d}}\quad\text{where}\quad% {\mathbf{e}}_{1,3}=\begin{bmatrix}0\\ 0\\ 1\end{bmatrix}.$ (4)

Recall that a rotation matrix has 3 degrees of freedom, while a unit vector has 2. We can still have one more parameter to extend from ${\mathbf{d}}$ to ${\mathbf{S}}$. In fact, without introducing an extra parameter, we already have enough ingredients to construct such a rotation matrix for (4). Using $\phi,\,\psi$ in (1), we have

 $\displaystyle{\mathbf{S}}_{0}=\begin{bmatrix}s_{\psi}&c_{\phi}c_{\psi}&s_{\phi% }c_{\psi}\\ -c_{\psi}&c_{\phi}s_{\psi}&s_{\phi}s_{\psi}\\ &-s_{\phi}&c_{\phi}\end{bmatrix}.$ (5)

Note again that when $c_{\phi}=\pm 1$, parameter $\psi$ can take any value.

Let the extra parameter be $\gamma$. Then all rotation matrices that satisfy (4) can be written in the following form:

 $\displaystyle{\mathbf{S}}:={\mathbf{S}}_{0}\cdot\text{Rot}_{z}({\gamma})=% \begin{bmatrix}s_{\psi}&c_{\phi}c_{\psi}&s_{\phi}c_{\psi}\\ -c_{\psi}&c_{\phi}s_{\psi}&s_{\phi}s_{\psi}\\ &-s_{\phi}&c_{\phi}\end{bmatrix}\begin{bmatrix}c_{\gamma}&-s_{\gamma}\\ s_{\gamma}&c_{\gamma}\\ &&1\end{bmatrix}.$ (6)

Then we can see that parameter $\gamma$ simply does not matter in ${\mathbf{R}}$, for

 $\displaystyle{\mathbf{R}}$ $\displaystyle={\mathbf{S}}\cdot\text{Rot}_{z}({\theta})\cdot{\mathbf{S}}^{T}$ $\displaystyle={\mathbf{S}}_{0}\cdot\text{Rot}_{z}({\gamma})\cdot\text{Rot}_{z}% ({\theta})\cdot\text{Rot}_{z}({-\gamma})\cdot{\mathbf{S}}_{0}^{T}$ $\displaystyle={\mathbf{S}}_{0}\cdot\text{Rot}_{z}({\theta})\cdot{\mathbf{S}}_{% 0}^{T}.$ (7)

In the future derivations, we will simply use ${\mathbf{S}}_{0}$ from (5).

We will show in the next blog that the rotation in (7) indeed rotates every vector in the original coordinate system by the angle $\theta$ with respect to the direction ${\mathbf{d}}$.