# Homogeneous transformation matrix (9)

Kinematics & Universal Numerics
August 19, 2019

## A small result about the minimal rotation.

In a previous blog, we claim that, every 3D rotation matrix ${\mathbf{S}}$ that has

 $\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)

in its last column is in the form of

 $\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}.$ (2)

What the rotation ${\mathbf{S}}$ do is align the $z$-axis with ${\mathbf{d}}$, so that we can perform a basic rotation around ${\mathbf{d}}$, that is the new $z$-axis, by right- (post-) multiplying $\text{Rot}_{z}({\theta})$. At the end, we revert the aligning operation by right-multiplying ${\mathbf{S}}^{T}$.

Note that the angle between the original $z$-axis and ${\mathbf{d}}$ is $\phi$, since

 ${\mathbf{d}}^{T}\begin{bmatrix}0\\ 0\\ 1\end{bmatrix}=d_{z}=c_{\phi}.$

However, the rotation angle of ${\mathbf{S}}_{0}$ is not exactly $\phi$, since

 $\displaystyle c_{\phi}\not\equiv\frac{s_{\psi}+s_{\psi}c_{\phi}+c_{\phi}-1}{2}% =\frac{\text{tr}({\mathbf{S}}_{0})-1}{2}.$ (3)

In fact,

 $c_{\phi}-\frac{s_{\psi}+s_{\psi}c_{\phi}+c_{\phi}-1}{2}=\frac{1}{2}(c_{\phi}+1% )(1-s_{\psi})\geq 0,$

so the rotation angle of ${\mathbf{S}}_{0}$ is always not less than $\phi$, given that $\cos\phi$ is decreasing in $\phi\in[0,\pi]$. Here we recall that when we convert a rotation matrix ${\mathbf{R}}$ into its axis-angle representation, the rotation angle is attained by

 $\theta=\displaystyle{\arccos\frac{\text{tr}({\mathbf{R}})-1}{2}}.$

What we want to find out is the value of $\gamma$, such that the angle of the rotation ${\mathbf{S}}={\mathbf{S}}_{0}\cdot\text{Rot}_{z}({\gamma})$ parametrized by $\gamma$ is exactly $\phi$. That is

 $\displaystyle 2c_{\phi}+1=\text{tr}({\mathbf{S}})$ $\displaystyle=(s_{\psi}c_{\gamma}+c_{\phi}c_{\psi}s_{\gamma})+(c_{\psi}s_{% \gamma}+c_{\phi}s_{\psi}c_{\gamma})+c_{\phi}$ $\displaystyle=(c_{\phi}+1)(s_{\psi}c_{\gamma}+c_{\psi}s_{\gamma})+c_{\phi}$ $\displaystyle=(c_{\phi}+1)s_{\psi+\gamma}+c_{\phi}.$

Rearranging terms yields

 $\displaystyle(c_{\phi}+1)(1-s_{\psi+\gamma})=0.$ (4)

If $c_{\phi}=-1$, then $\phi=\pi$ and

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

Rotating any vector perpendicular to the $z$-axis by angle $\pi$ can achieve this, so the simplest choice is $\psi-\gamma=\pi/2$, and

 $\displaystyle{\mathbf{S}}=\text{Rot}_{x}({\pi})=\begin{bmatrix}1&\\ &-1\\ &&-1\end{bmatrix}.$

Otherwise, if $c_{\phi}\neq-1$, then $s_{\psi+\gamma}=1$ and we can choose $\gamma=\pi/2-\psi$. Then

 $\displaystyle{\mathbf{S}}={\mathbf{S}}_{0}\cdot\text{Rot}_{z}({\gamma})$ $\displaystyle=\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}s_{\psi}&-c_{\psi}\\ c_{\psi}&s_{\psi}\\ &&1\end{bmatrix}$ $\displaystyle=\begin{bmatrix}1+c_{\psi}^{2}(c_{\phi}-1)&s_{\psi}c_{\psi}(c_{% \phi}-1)&s_{\phi}c_{\psi}\\ s_{\psi}c_{\psi}(c_{\phi}-1)&1+s_{\psi}^{2}(c_{\phi}-1)&s_{\phi}s_{\psi}\\ -s_{\phi}c_{\psi}&-s_{\phi}s_{\psi}&c_{\phi}\end{bmatrix}.$ (5)

When the rotation axis ${\mathbf{d}}$ is not trivially $[0,0,1]^{T}$ and hence $c_{\phi}\neq 1$ and $s_{\phi}\neq 0$, the rotation axis of ${\mathbf{S}}$ is

 $\displaystyle{\mathbf{d}}=\begin{bmatrix}d_{x}\\ d_{y}\\ d_{z}\end{bmatrix}=\frac{1}{2s_{\phi}}\begin{bmatrix}r_{32}-r_{23}\\ r_{13}-r_{31}\\ r_{21}-r_{12}\end{bmatrix}=\frac{1}{2s_{\phi}}\begin{bmatrix}-2s_{\phi}s_{\psi% }\\ 2s_{\phi}c_{\psi}\\ \par \end{bmatrix}=\begin{bmatrix}-s_{\psi}\\ c_{\psi}\\ \par \end{bmatrix},$

always a vector perpendicular to the $z$-axis.