01
Composition of finite rotations
Unless otherwise stated, the active rotation convention introduced in Section 21.1 is used throughout this section.
Euler's rotation theorem states: “in three-dimensional space, any displacement of a rigid body such that a point on the rigid body remains fixed, is equivalent to a single rotation about some axis that runs through the fixed point”, [1] . It also follows that the composition of two rotations is a rotation.
In the middle of the nineteenth century (1840) the French mathematician Olinde Rodrigues demonstrated the formula for composition of large rotations, [2] . Let’s consider two rotations:
rotation (a) of angle α \alpha α around the unit vector l \htmlClass{fea-math-bold-italic}{\boldsymbol l} l : a = ( l , α ) \htmlClass{fea-math-bold-italic}{\boldsymbol a}=(\htmlClass{fea-math-bold-italic}{\boldsymbol l},\alpha) a = ( l , α ) , and rotation (b) of angle β \beta β around the unit vector m \htmlClass{fea-math-bold-italic}{\boldsymbol m} m : b = ( m , β ) \htmlClass{fea-math-bold-italic}{\boldsymbol b}=(\htmlClass{fea-math-bold-italic}{\boldsymbol m},\beta) b = ( m , β ) .
The composition of these two rotations gives the rotation of angle γ \gamma γ around the unit vector n \htmlClass{fea-math-bold-italic}{\boldsymbol n} n : c = ( n , γ ) \htmlClass{fea-math-bold-italic}{\boldsymbol c}=(\htmlClass{fea-math-bold-italic}{\boldsymbol n},\gamma) c = ( n , γ ) .
The result of composition:
c = a ∘ b o r ( n , γ ) = ( l , α ) ∘ ( m , β ) \htmlClass{fea-math-bold-italic}{\boldsymbol c}=\htmlClass{fea-math-bold-italic}{\boldsymbol a}\circ\htmlClass{fea-math-bold-italic}{\boldsymbol b}\qquad\mathit{or}\qquad(\htmlClass{fea-math-bold-italic}{\boldsymbol n},\gamma)=(\htmlClass{fea-math-bold-italic}{\boldsymbol l},\alpha)\circ(\htmlClass{fea-math-bold-italic}{\boldsymbol m},\beta) c = a ∘ b or ( n , γ ) = ( l , α ) ∘ ( m , β )
The composition of finite rotations is not commutative; the result depends on the order of application of the rotations! In the composition considered here, rotation (b) is applied first and rotation (a) second. The angle γ \gamma γ and the unit vector n \htmlClass{fea-math-bold-italic}{\boldsymbol n} n are:
s i n γ 2 n = s i n α 2 c o s β 2 l + c o s α 2 s i n β 2 m + s i n α 2 s i n β 2 l × m c o s γ 2 = c o s α 2 c o s β 2 − s i n α 2 s i n β 2 l ⋅ m (*) \begin{aligned}\mathop{\mathit{sin}}\frac{\gamma}{2}\htmlClass{fea-math-bold-italic}{\boldsymbol n}&=\mathop{\mathit{sin}}\frac{\alpha}{2}\mathop{\mathit{cos}}\frac{\beta}{2}\htmlClass{fea-math-bold-italic}{\boldsymbol l}+\mathop{\mathit{cos}}\frac{\alpha}{2}\mathop{\mathit{sin}}\frac{\beta}{2}\htmlClass{fea-math-bold-italic}{\boldsymbol m}+\mathop{\mathit{sin}}\frac{\alpha}{2}\mathop{\mathit{sin}}\frac{\beta}{2}\htmlClass{fea-math-bold-italic}{\boldsymbol l}\times\htmlClass{fea-math-bold-italic}{\boldsymbol m}\\
\mathop{\mathit{cos}}\frac{\gamma}{2}&=\mathop{\mathit{cos}}\frac{\alpha}{2}\mathop{\mathit{cos}}\frac{\beta}{2}-\mathop{\mathit{sin}}\frac{\alpha}{2}\mathop{\mathit{sin}}\frac{\beta}{2}\htmlClass{fea-math-bold-italic}{\boldsymbol l}\cdot\htmlClass{fea-math-bold-italic}{\boldsymbol m}
\end{aligned}\tag{*} sin 2 γ n cos 2 γ = sin 2 α cos 2 β l + cos 2 α sin 2 β m + sin 2 α sin 2 β l × m = cos 2 α cos 2 β − sin 2 α sin 2 β l ⋅ m ( * )
where l ⋅ m \htmlClass{fea-math-bold-italic}{\boldsymbol l}\cdot\htmlClass{fea-math-bold-italic}{\boldsymbol m} l ⋅ m denotes the dot product and l × m \htmlClass{fea-math-bold-italic}{\boldsymbol l}\times\htmlClass{fea-math-bold-italic}{\boldsymbol m} l × m denotes the cross product.1) Obviously:
l ⋅ l = 1 m ⋅ m = 1 n ⋅ n = 1 \htmlClass{fea-math-bold-italic}{\boldsymbol l}\cdot\htmlClass{fea-math-bold-italic}{\boldsymbol l}=1\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol m}\cdot\htmlClass{fea-math-bold-italic}{\boldsymbol m}=1\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol n}\cdot\htmlClass{fea-math-bold-italic}{\boldsymbol n}=1 l ⋅ l = 1 m ⋅ m = 1 n ⋅ n = 1
The two equations (*) may be written in a nicer form:
c n = ( b 0 a l + a 0 b m + a l × b m a 0 b 0 − a l ⋅ b m ) \htmlClass{fea-math-bold-italic}{\boldsymbol c}_n=\left(b_0\htmlClass{fea-math-bold-italic}{\boldsymbol a}_l+a_0\htmlClass{fea-math-bold-italic}{\boldsymbol b}_m+\htmlClass{fea-math-bold-italic}{\boldsymbol a}_l\times\htmlClass{fea-math-bold-italic}{\boldsymbol b}_m\quad a_0b_0-\htmlClass{fea-math-bold-italic}{\boldsymbol a}_l\cdot\htmlClass{fea-math-bold-italic}{\boldsymbol b}_m\right) c n = ( b 0 a l + a 0 b m + a l × b m a 0 b 0 − a l ⋅ b m )
where the vectors a l \htmlClass{fea-math-bold-italic}{\boldsymbol a}_l a l and b m \htmlClass{fea-math-bold-italic}{\boldsymbol b}_m b m are:
a l = l s i n α 2 = { l x l y l z } s i n α 2 b m = m s i n β 2 = { m x m y m z } s i n β 2 c n = n s i n γ 2 = { n x n y n z } s i n γ 2 \htmlClass{fea-math-bold-italic}{\boldsymbol a}_l=\htmlClass{fea-math-bold-italic}{\boldsymbol l}\mathop{\mathit{sin}}\frac{\alpha}{2}=\begin{Bmatrix}l_x\\l_y\\l_z\end{Bmatrix}\mathop{\mathit{sin}}\frac{\alpha}{2}\qquad
\htmlClass{fea-math-bold-italic}{\boldsymbol b}_m=\htmlClass{fea-math-bold-italic}{\boldsymbol m}\mathop{\mathit{sin}}\frac{\beta}{2}=\begin{Bmatrix}m_x\\m_y\\m_z\end{Bmatrix}\mathop{\mathit{sin}}\frac{\beta}{2}\qquad
\htmlClass{fea-math-bold-italic}{\boldsymbol c}_n=\htmlClass{fea-math-bold-italic}{\boldsymbol n}\mathop{\mathit{sin}}\frac{\gamma}{2}=\begin{Bmatrix}n_x\\n_y\\n_z\end{Bmatrix}\mathop{\mathit{sin}}\frac{\gamma}{2} a l = l sin 2 α = ⎩ ⎨ ⎧ l x l y l z ⎭ ⎬ ⎫ sin 2 α b m = m sin 2 β = ⎩ ⎨ ⎧ m x m y m z ⎭ ⎬ ⎫ sin 2 β c n = n sin 2 γ = ⎩ ⎨ ⎧ n x n y n z ⎭ ⎬ ⎫ sin 2 γ
and:
a 0 = c o s α 2 b 0 = c o s β 2 a_0=\mathop{\mathit{cos}}\frac{\alpha}{2}\qquad b_0=\mathop{\mathit{cos}}\frac{\beta}{2} a 0 = cos 2 α b 0 = cos 2 β
02
Quaternions
More elegant expressions are obtained if we represent rotations as quaternions. More about quaternions in [3] , [4] . Throughout this section, quaternions are written in scalar-first form. Let’s define two quaternions a \htmlClass{fea-math-bold-italic}{\boldsymbol a} a and b \htmlClass{fea-math-bold-italic}{\boldsymbol b} b as:
a = { a 0 a l } = { c o s α 2 l s i n α 2 } = { c o s α 2 l x s i n α 2 l y s i n α 2 l z s i n α 2 } = { a 0 a 1 a 2 a 3 } \htmlClass{fea-math-bold-italic}{\boldsymbol a}=\begin{Bmatrix}a_0\\\htmlClass{fea-math-bold-italic}{\boldsymbol a}_l\end{Bmatrix}=\begin{Bmatrix}\mathop{\mathit{cos}}\frac{\alpha}{2}\\\htmlClass{fea-math-bold-italic}{\boldsymbol l}\mathop{\mathit{sin}}\frac{\alpha}{2}\end{Bmatrix}=\begin{Bmatrix}\mathop{\mathit{cos}}\frac{\alpha}{2}\\l_x\mathop{\mathit{sin}}\frac{\alpha}{2}\\l_y\mathop{\mathit{sin}}\frac{\alpha}{2}\\l_z\mathop{\mathit{sin}}\frac{\alpha}{2}\end{Bmatrix}=\begin{Bmatrix}a_0\\a_1\\a_2\\a_3\end{Bmatrix} a = { a 0 a l } = { cos 2 α l sin 2 α } = ⎩ ⎨ ⎧ cos 2 α l x sin 2 α l y sin 2 α l z sin 2 α ⎭ ⎬ ⎫ = ⎩ ⎨ ⎧ a 0 a 1 a 2 a 3 ⎭ ⎬ ⎫
and:
b = { b 0 b m } = { c o s β 2 m s i n β 2 } = { c o s β 2 m x s i n β 2 m y s i n β 2 m z s i n β 2 } = { b 0 b 1 b 2 b 3 } \htmlClass{fea-math-bold-italic}{\boldsymbol b}=\begin{Bmatrix}b_0\\\htmlClass{fea-math-bold-italic}{\boldsymbol b}_m\end{Bmatrix}=\begin{Bmatrix}\mathop{\mathit{cos}}\frac{\beta}{2}\\\htmlClass{fea-math-bold-italic}{\boldsymbol m}\mathop{\mathit{sin}}\frac{\beta}{2}\end{Bmatrix}=\begin{Bmatrix}\mathop{\mathit{cos}}\frac{\beta}{2}\\m_x\mathop{\mathit{sin}}\frac{\beta}{2}\\m_y\mathop{\mathit{sin}}\frac{\beta}{2}\\m_z\mathop{\mathit{sin}}\frac{\beta}{2}\end{Bmatrix}=\begin{Bmatrix}b_0\\b_1\\b_2\\b_3\end{Bmatrix} b = { b 0 b m } = { cos 2 β m sin 2 β } = ⎩ ⎨ ⎧ cos 2 β m x sin 2 β m y sin 2 β m z sin 2 β ⎭ ⎬ ⎫ = ⎩ ⎨ ⎧ b 0 b 1 b 2 b 3 ⎭ ⎬ ⎫
Evidently, when a quaternion represents a rotation:
∥ a ∥ = a T a = 1 ∥ b ∥ = b T b = 1 \|\htmlClass{fea-math-bold-italic}{\boldsymbol a}\|=\htmlClass{fea-math-bold-italic}{\boldsymbol a}^T\htmlClass{fea-math-bold-italic}{\boldsymbol a}=1\qquad\|\htmlClass{fea-math-bold-italic}{\boldsymbol b}\|=\htmlClass{fea-math-bold-italic}{\boldsymbol b}^T\htmlClass{fea-math-bold-italic}{\boldsymbol b}=1 ∥ a ∥ = a T a = 1 ∥ b ∥ = b T b = 1
Quaternion multiplication used here is the Hamilton product. The composition (multiplication) of two quaternions gives, [3] , [4] :
c = { c 0 c 1 c 2 c 3 } = a ∘ b = { c o s γ 2 n x s i n γ 2 n y s i n γ 2 n z s i n γ 2 } = { a 0 b 0 − a 1 b 1 − a 2 b 2 − a 3 b 3 a 0 b 1 + a 1 b 0 + a 2 b 3 − a 3 b 2 a 0 b 2 − a 1 b 3 + a 2 b 0 + a 3 b 1 a 0 b 3 + a 1 b 2 − a 2 b 1 + a 3 b 0 } (**) \htmlClass{fea-math-bold-italic}{\boldsymbol c}=\begin{Bmatrix}c_0\\c_1\\c_2\\c_3\end{Bmatrix}=\htmlClass{fea-math-bold-italic}{\boldsymbol a}\circ\htmlClass{fea-math-bold-italic}{\boldsymbol b}
=\begin{Bmatrix}\mathop{\mathit{cos}}\frac{\gamma}{2}\\n_x\mathop{\mathit{sin}}\frac{\gamma}{2}\\n_y\mathop{\mathit{sin}}\frac{\gamma}{2}\\n_z\mathop{\mathit{sin}}\frac{\gamma}{2}\end{Bmatrix}
=\begin{Bmatrix}
a_0b_0-a_1b_1-a_2b_2-a_3b_3\\
a_0b_1+a_1b_0+a_2b_3-a_3b_2\\
a_0b_2-a_1b_3+a_2b_0+a_3b_1\\
a_0b_3+a_1b_2-a_2b_1+a_3b_0
\end{Bmatrix}\tag{**} c = ⎩ ⎨ ⎧ c 0 c 1 c 2 c 3 ⎭ ⎬ ⎫ = a ∘ b = ⎩ ⎨ ⎧ cos 2 γ n x sin 2 γ n y sin 2 γ n z sin 2 γ ⎭ ⎬ ⎫ = ⎩ ⎨ ⎧ a 0 b 0 − a 1 b 1 − a 2 b 2 − a 3 b 3 a 0 b 1 + a 1 b 0 + a 2 b 3 − a 3 b 2 a 0 b 2 − a 1 b 3 + a 2 b 0 + a 3 b 1 a 0 b 3 + a 1 b 2 − a 2 b 1 + a 3 b 0 ⎭ ⎬ ⎫ ( ** )
Quaternions may also be considered as an extension of complex numbers and they can be written like this:
a = a 0 + a 1 i + a 2 j + a 3 k a=a_0+a_1\htmlClass{fea-math-bold-italic}{\boldsymbol i}+a_2\htmlClass{fea-math-bold-italic}{\boldsymbol j}+a_3\htmlClass{fea-math-bold-italic}{\boldsymbol k} a = a 0 + a 1 i + a 2 j + a 3 k
Composition of two rotations is equivalent to the multiplication of two quaternions written in this form and considering these basic multiplication rules:
i 2 = j 2 = k 2 = − 1 i j = k j i = − k j k = i k j = − i k i = j i k = − j \begin{gathered}
\htmlClass{fea-math-bold-italic}{\boldsymbol i}^2=\htmlClass{fea-math-bold-italic}{\boldsymbol j}^2=\htmlClass{fea-math-bold-italic}{\boldsymbol k}^2=-1\\
\htmlClass{fea-math-bold-italic}{\boldsymbol i}\htmlClass{fea-math-bold-italic}{\boldsymbol j}=\htmlClass{fea-math-bold-italic}{\boldsymbol k}\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol j}\htmlClass{fea-math-bold-italic}{\boldsymbol i}=-\htmlClass{fea-math-bold-italic}{\boldsymbol k}\\
\htmlClass{fea-math-bold-italic}{\boldsymbol j}\htmlClass{fea-math-bold-italic}{\boldsymbol k}=\htmlClass{fea-math-bold-italic}{\boldsymbol i}\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol k}\htmlClass{fea-math-bold-italic}{\boldsymbol j}=-\htmlClass{fea-math-bold-italic}{\boldsymbol i}\\
\htmlClass{fea-math-bold-italic}{\boldsymbol k}\htmlClass{fea-math-bold-italic}{\boldsymbol i}=\htmlClass{fea-math-bold-italic}{\boldsymbol j}\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol i}\htmlClass{fea-math-bold-italic}{\boldsymbol k}=-\htmlClass{fea-math-bold-italic}{\boldsymbol j}
\end{gathered} i 2 = j 2 = k 2 = − 1 i j = k j i = − k j k = i k j = − i k i = j i k = − j
Therefore:
a ∘ b = ( a 0 + a 1 i + a 2 j + a 3 k ) ( b 0 + b 1 i + b 2 j + b 3 k ) = a 0 b 0 + a 0 b 1 i + a 0 b 2 j + a 0 b 3 k + a 1 b 0 i − a 1 b 1 + a 1 b 2 k − a 1 b 3 j + a 2 b 0 j − a 2 b 1 k − a 2 b 2 + a 2 b 3 i + a 3 b 0 k + a 3 b 1 j − a 3 b 2 i − a 3 b 3 = a 0 b 0 − a 1 b 1 − a 2 b 2 − a 3 b 3 + ( a 0 b 1 + a 1 b 0 + a 2 b 3 − a 3 b 2 ) i + ( a 0 b 2 − a 1 b 3 + a 2 b 0 + a 3 b 1 ) j + ( a 0 b 3 + a 1 b 2 − a 2 b 1 + a 3 b 0 ) k \begin{aligned}
a\circ b&=(a_0+a_1\htmlClass{fea-math-bold-italic}{\boldsymbol i}+a_2\htmlClass{fea-math-bold-italic}{\boldsymbol j}+a_3\htmlClass{fea-math-bold-italic}{\boldsymbol k})(b_0+b_1\htmlClass{fea-math-bold-italic}{\boldsymbol i}+b_2\htmlClass{fea-math-bold-italic}{\boldsymbol j}+b_3\htmlClass{fea-math-bold-italic}{\boldsymbol k})\\
&=a_0b_0+a_0b_1\htmlClass{fea-math-bold-italic}{\boldsymbol i}+a_0b_2\htmlClass{fea-math-bold-italic}{\boldsymbol j}+a_0b_3\htmlClass{fea-math-bold-italic}{\boldsymbol k}\\
&\quad+a_1b_0\htmlClass{fea-math-bold-italic}{\boldsymbol i}-a_1b_1+a_1b_2\htmlClass{fea-math-bold-italic}{\boldsymbol k}-a_1b_3\htmlClass{fea-math-bold-italic}{\boldsymbol j}\\
&\quad+a_2b_0\htmlClass{fea-math-bold-italic}{\boldsymbol j}-a_2b_1\htmlClass{fea-math-bold-italic}{\boldsymbol k}-a_2b_2+a_2b_3\htmlClass{fea-math-bold-italic}{\boldsymbol i}\\
&\quad+a_3b_0\htmlClass{fea-math-bold-italic}{\boldsymbol k}+a_3b_1\htmlClass{fea-math-bold-italic}{\boldsymbol j}-a_3b_2\htmlClass{fea-math-bold-italic}{\boldsymbol i}-a_3b_3\\
&=a_0b_0-a_1b_1-a_2b_2-a_3b_3\\
&\quad+(a_0b_1+a_1b_0+a_2b_3-a_3b_2)\htmlClass{fea-math-bold-italic}{\boldsymbol i}\\
&\quad+(a_0b_2-a_1b_3+a_2b_0+a_3b_1)\htmlClass{fea-math-bold-italic}{\boldsymbol j}\\
&\quad+(a_0b_3+a_1b_2-a_2b_1+a_3b_0)\htmlClass{fea-math-bold-italic}{\boldsymbol k}
\end{aligned} a ∘ b = ( a 0 + a 1 i + a 2 j + a 3 k ) ( b 0 + b 1 i + b 2 j + b 3 k ) = a 0 b 0 + a 0 b 1 i + a 0 b 2 j + a 0 b 3 k + a 1 b 0 i − a 1 b 1 + a 1 b 2 k − a 1 b 3 j + a 2 b 0 j − a 2 b 1 k − a 2 b 2 + a 2 b 3 i + a 3 b 0 k + a 3 b 1 j − a 3 b 2 i − a 3 b 3 = a 0 b 0 − a 1 b 1 − a 2 b 2 − a 3 b 3 + ( a 0 b 1 + a 1 b 0 + a 2 b 3 − a 3 b 2 ) i + ( a 0 b 2 − a 1 b 3 + a 2 b 0 + a 3 b 1 ) j + ( a 0 b 3 + a 1 b 2 − a 2 b 1 + a 3 b 0 ) k
This result is identical to (**). The product of two quaternions is not commutative!
The conjugate of:
a = a 0 + a 1 i + a 2 j + a 3 k a=a_0+a_1\htmlClass{fea-math-bold-italic}{\boldsymbol i}+a_2\htmlClass{fea-math-bold-italic}{\boldsymbol j}+a_3\htmlClass{fea-math-bold-italic}{\boldsymbol k} a = a 0 + a 1 i + a 2 j + a 3 k
is:
a ∗ = a 0 − a 1 i − a 2 j − a 3 k a^*=a_0-a_1\htmlClass{fea-math-bold-italic}{\boldsymbol i}-a_2\htmlClass{fea-math-bold-italic}{\boldsymbol j}-a_3\htmlClass{fea-math-bold-italic}{\boldsymbol k} a ∗ = a 0 − a 1 i − a 2 j − a 3 k
and:
a a ∗ = ∣ a ∣ 2 = a 0 2 + a 1 2 + a 2 2 + a 3 2 aa^*=|a|^2=a_0^2+a_1^2+a_2^2+a_3^2 a a ∗ = ∣ a ∣ 2 = a 0 2 + a 1 2 + a 2 2 + a 3 2
03
Rotation representations
There are several ways to describe a rotation; four of them are considered here.
The most common and most used is the rotation matrix R \htmlClass{fea-math-bold-italic}{\boldsymbol R} R (see Section 21.1 ). The composition of two rotations R 1 \htmlClass{fea-math-bold-italic}{\boldsymbol R}_1 R 1 and R 2 \htmlClass{fea-math-bold-italic}{\boldsymbol R}_2 R 2 (R 1 \htmlClass{fea-math-bold-italic}{\boldsymbol R}_1 R 1 is applied first) is:
R = R 2 R 1 \htmlClass{fea-math-bold-italic}{\boldsymbol R}=\htmlClass{fea-math-bold-italic}{\boldsymbol R}_2\htmlClass{fea-math-bold-italic}{\boldsymbol R}_1 R = R 2 R 1
The axis-angle representation describes a rotation of angle φ \varphi φ and direction defined by the unit vector n = ( n x n y n z ) T \htmlClass{fea-math-bold-italic}{\boldsymbol n}=(n_x\ n_y\ n_z)^T n = ( n x n y n z ) T . Using the notation introduced in Section 21.1 , the vector form is:
ρ = φ n , ∥ ρ ∥ = φ . \htmlClass{fea-math-bold-italic}{\boldsymbol{\rho}}=\varphi\htmlClass{fea-math-bold-italic}{\boldsymbol n},\qquad\|\htmlClass{fea-math-bold-italic}{\boldsymbol{\rho}}\|=\varphi. ρ = φ n , ∥ ρ ∥ = φ .
Here ρ \htmlClass{fea-math-bold-italic}{\boldsymbol{\rho}} ρ is a three-component rotation vector. The axis-angle parameter form is:
r = [ n x n y n z φ ] . \htmlClass{fea-math-bold-italic}{\boldsymbol r}=\begin{bmatrix}n_x&n_y&n_z&\varphi\end{bmatrix}. r = [ n x n y n z φ ] .
This is a four-parameter axis-angle array, as used by MATLAB functions such as axang2rotm and rotm2axang. The two forms contain the same physical information but are not the same mathematical object.
The equivalent rotation matrix (see Section 21.1 ) is expressed in axis-angle parameters:
R a a = [ c o s φ + n x 2 ( 1 − c o s φ ) n x n y ( 1 − c o s φ ) − n z s i n φ n z n x ( 1 − c o s φ ) + n y s i n φ n x n y ( 1 − c o s φ ) + n z s i n φ c o s φ + n y 2 ( 1 − c o s φ ) n y n z ( 1 − c o s φ ) − n x s i n φ n z n x ( 1 − c o s φ ) − n y s i n φ n y n z ( 1 − c o s φ ) + n x s i n φ c o s φ + n z 2 ( 1 − c o s φ ) ] \htmlClass{fea-math-bold-italic}{\boldsymbol R}_{aa}=\begin{bmatrix}
\mathop{\mathit{cos}}\varphi+n_x^2(1-\mathop{\mathit{cos}}\varphi)&n_xn_y(1-\mathop{\mathit{cos}}\varphi)-n_z\mathop{\mathit{sin}}\varphi&n_zn_x(1-\mathop{\mathit{cos}}\varphi)+n_y\mathop{\mathit{sin}}\varphi\\
n_xn_y(1-\mathop{\mathit{cos}}\varphi)+n_z\mathop{\mathit{sin}}\varphi&\mathop{\mathit{cos}}\varphi+n_y^2(1-\mathop{\mathit{cos}}\varphi)&n_yn_z(1-\mathop{\mathit{cos}}\varphi)-n_x\mathop{\mathit{sin}}\varphi\\
n_zn_x(1-\mathop{\mathit{cos}}\varphi)-n_y\mathop{\mathit{sin}}\varphi&n_yn_z(1-\mathop{\mathit{cos}}\varphi)+n_x\mathop{\mathit{sin}}\varphi&\mathop{\mathit{cos}}\varphi+n_z^2(1-\mathop{\mathit{cos}}\varphi)
\end{bmatrix} R aa = cos φ + n x 2 ( 1 − cos φ ) n x n y ( 1 − cos φ ) + n z sin φ n z n x ( 1 − cos φ ) − n y sin φ n x n y ( 1 − cos φ ) − n z sin φ cos φ + n y 2 ( 1 − cos φ ) n y n z ( 1 − cos φ ) + n x sin φ n z n x ( 1 − cos φ ) + n y sin φ n y n z ( 1 − cos φ ) − n x sin φ cos φ + n z 2 ( 1 − cos φ )
Quaternion representation is one of the most utilized:
q = { q 0 q 1 q 2 q 3 } = { c o s φ 2 n x s i n φ 2 n y s i n φ 2 n z s i n φ 2 } = { c o s φ 2 n s i n φ 2 } \htmlClass{fea-math-bold-italic}{\boldsymbol q}=\begin{Bmatrix}q_0\\q_1\\q_2\\q_3\end{Bmatrix}
=\begin{Bmatrix}\mathop{\mathit{cos}}\frac{\varphi}{2}\\n_x\mathop{\mathit{sin}}\frac{\varphi}{2}\\n_y\mathop{\mathit{sin}}\frac{\varphi}{2}\\n_z\mathop{\mathit{sin}}\frac{\varphi}{2}\end{Bmatrix}
=\begin{Bmatrix}\mathop{\mathit{cos}}\frac{\varphi}{2}\\\htmlClass{fea-math-bold-italic}{\boldsymbol n}\mathop{\mathit{sin}}\frac{\varphi}{2}\end{Bmatrix} q = ⎩ ⎨ ⎧ q 0 q 1 q 2 q 3 ⎭ ⎬ ⎫ = ⎩ ⎨ ⎧ cos 2 φ n x sin 2 φ n y sin 2 φ n z sin 2 φ ⎭ ⎬ ⎫ = { cos 2 φ n sin 2 φ }
where:
q T q = q 0 2 + q 1 2 + q 2 2 + q 3 2 = 1 \htmlClass{fea-math-bold-italic}{\boldsymbol q}^T\htmlClass{fea-math-bold-italic}{\boldsymbol q}=q_0^2+q_1^2+q_2^2+q_3^2=1 q T q = q 0 2 + q 1 2 + q 2 2 + q 3 2 = 1
A unit quaternion q q q and its opposite − q -q − q represent the same finite rotation.
The equivalent rotation matrix expressed in quaternion elements is:
R q = [ 1 − 2 ( q 2 2 + q 3 2 ) 2 ( q 1 q 2 − q 0 q 3 ) 2 ( q 1 q 3 + q 0 q 2 ) 2 ( q 1 q 2 + q 0 q 3 ) 1 − 2 ( q 3 2 + q 1 2 ) 2 ( q 2 q 3 − q 0 q 1 ) 2 ( q 1 q 3 − q 0 q 2 ) 2 ( q 2 q 3 + q 0 q 1 ) 1 − 2 ( q 1 2 + q 2 2 ) ] \htmlClass{fea-math-bold-italic}{\boldsymbol R}_q=\begin{bmatrix}
1-2(q_2^2+q_3^2)&2(q_1q_2-q_0q_3)&2(q_1q_3+q_0q_2)\\
2(q_1q_2+q_0q_3)&1-2(q_3^2+q_1^2)&2(q_2q_3-q_0q_1)\\
2(q_1q_3-q_0q_2)&2(q_2q_3+q_0q_1)&1-2(q_1^2+q_2^2)
\end{bmatrix} R q = 1 − 2 ( q 2 2 + q 3 2 ) 2 ( q 1 q 2 + q 0 q 3 ) 2 ( q 1 q 3 − q 0 q 2 ) 2 ( q 1 q 2 − q 0 q 3 ) 1 − 2 ( q 3 2 + q 1 2 ) 2 ( q 2 q 3 + q 0 q 1 ) 2 ( q 1 q 3 + q 0 q 2 ) 2 ( q 2 q 3 − q 0 q 1 ) 1 − 2 ( q 1 2 + q 2 2 )
Obviously, substituting the expressions of q 0 q_0 q 0 , q 1 q_1 q 1 , q 2 q_2 q 2 and q 3 q_3 q 3 in R q \htmlClass{fea-math-bold-italic}{\boldsymbol R}_q R q , the R a a \htmlClass{fea-math-bold-italic}{\boldsymbol R}_{aa} R aa rotation matrix is obtained immediately.
Tait–Bryan angles. The three angles, called yaw, pitch and roll, are ( ψ θ φ ) (\psi\ \theta\ \varphi) ( ψ θ φ ) , see Section 21.2 : R T B = R a c t i v e T \htmlClass{fea-math-bold-italic}{\boldsymbol R}_{\mathit{TB}}=\htmlClass{fea-math-bold-italic}{\boldsymbol R}_{\mathit{active}}^T R TB = R active T . The rotation matrix is:
R T B = [ c o s ψ c o s θ s i n ψ c o s θ − s i n θ − s i n ψ c o s φ + c o s ψ s i n θ s i n φ c o s ψ c o s φ + s i n ψ s i n θ s i n φ c o s θ s i n φ s i n ψ s i n φ + c o s ψ s i n θ c o s φ − c o s ψ s i n φ + s i n ψ s i n θ c o s φ c o s θ c o s φ ] \htmlClass{fea-math-bold-italic}{\boldsymbol R}_{\mathit{TB}}=\begin{bmatrix}
\mathop{\mathit{cos}}\psi\mathop{\mathit{cos}}\theta&\mathop{\mathit{sin}}\psi\mathop{\mathit{cos}}\theta&-\mathop{\mathit{sin}}\theta\\
-\mathop{\mathit{sin}}\psi\mathop{\mathit{cos}}\varphi+\mathop{\mathit{cos}}\psi\mathop{\mathit{sin}}\theta\mathop{\mathit{sin}}\varphi&\mathop{\mathit{cos}}\psi\mathop{\mathit{cos}}\varphi+\mathop{\mathit{sin}}\psi\mathop{\mathit{sin}}\theta\mathop{\mathit{sin}}\varphi&\mathop{\mathit{cos}}\theta\mathop{\mathit{sin}}\varphi\\
\mathop{\mathit{sin}}\psi\mathop{\mathit{sin}}\varphi+\mathop{\mathit{cos}}\psi\mathop{\mathit{sin}}\theta\mathop{\mathit{cos}}\varphi&-\mathop{\mathit{cos}}\psi\mathop{\mathit{sin}}\varphi+\mathop{\mathit{sin}}\psi\mathop{\mathit{sin}}\theta\mathop{\mathit{cos}}\varphi&\mathop{\mathit{cos}}\theta\mathop{\mathit{cos}}\varphi
\end{bmatrix} R TB = cos ψ cos θ − sin ψ cos φ + cos ψ sin θ sin φ sin ψ sin φ + cos ψ sin θ cos φ sin ψ cos θ cos ψ cos φ + sin ψ sin θ sin φ − cos ψ sin φ + sin ψ sin θ cos φ − sin θ cos θ sin φ cos θ cos φ
04
MATLAB conversions
MATLAB commands to convert different rotation representations are listed below. For the relationship between quaternions and Tait–Bryan angles, see also [5] .
The MATLAB functions listed below use the active rotation convention adopted in Section 21.1 . For Euler-angle conversions, MATLAB uses the intrinsic “ZYX” sequence by default, corresponding to yaw–pitch–roll. This is the same axis order used in Section 21.2 ; however, because Section 21.2 uses the global-to-local matrix convention, the corresponding rotation matrix is the transpose of MATLAB’s active rotation matrix.
From / To Rotation matrixR R R Axis-angler r r Quaternionq q q Tait–Bryan anglese e e
Rotation matrix R R R — rotm2axang(R)rotm2quat(R)rotm2eul(R,"ZYX")
Axis-angle r r r axang2rotm(r)— axang2quat(r)—
Quaternion q q q quat2rotm(q)quat2axang(q)— quat2eul(q,"ZYX")
Tait–Bryan angles e e e eul2rotm(e,"ZYX")— eul2quat(e,"ZYX")—
R T B = e u l 2 r o t m ( e , " Z Y X " ) T \htmlClass{fea-math-bold-italic}{\boldsymbol R}_{\mathit{TB}}=\mathit{eul2rotm}(e,\mathit{"ZYX"})^T R TB = eul2rotm ( e , "ZYX" ) T
e = r o t m 2 e u l ( R T B T , " Z Y X " ) e=\mathit{rotm2eul}(\htmlClass{fea-math-bold-italic}{\boldsymbol R}_{\mathit{TB}}^T,\mathit{"ZYX"}) e = rotm2eul ( R TB T , "ZYX" )
These modern conversion functions are provided by Robotics System Toolbox .
The legacy functions vrrotmat2vec and vrrotvec2mat are deprecated and scheduled for removal. The modern functions rotm2axang and axang2rotm should be used instead.
05
Example
Let's consider two rotations:
a) α = π 4 \alpha=\dfrac{\pi}{4} α = 4 π around the direction defined by the vector d 1 = [ 1 3 2 ] \htmlClass{fea-math-bold-italic}{\boldsymbol d}_1=\begin{bmatrix}1&3&2\end{bmatrix} d 1 = [ 1 3 2 ] . Direction cosines: l = d 1 / ∥ d 1 ∥ \htmlClass{fea-math-bold-italic}{\boldsymbol l}=\htmlClass{fea-math-bold-italic}{\boldsymbol d}_1/\|\htmlClass{fea-math-bold-italic}{\boldsymbol d}_1\| l = d 1 /∥ d 1 ∥ .
b) β = π 3 \beta=\dfrac{\pi}{3} β = 3 π around the direction defined by the vector d 2 = [ 2 − 1 1 ] \htmlClass{fea-math-bold-italic}{\boldsymbol d}_2=\begin{bmatrix}2&-1&1\end{bmatrix} d 2 = [ 2 − 1 1 ] . Direction cosines: m = d 2 / ∥ d 2 ∥ \htmlClass{fea-math-bold-italic}{\boldsymbol m}=\htmlClass{fea-math-bold-italic}{\boldsymbol d}_2/\|\htmlClass{fea-math-bold-italic}{\boldsymbol d}_2\| m = d 2 /∥ d 2 ∥ .
The composition of these two rotations, first rotation (a) and then rotation (b), can be performed with these MATLAB programs:
Using rotation matrices (run comp1):
comp1.m Copy
% comp1
al=pi/4;
l=[1 3 2]; l=l/norm(l);
ra=[l al];
be=pi/3;
m=[2 -1 1]; m=m/norm(m);
rb=[m be];
Ra=axa2R(ra); % convert axis-angle to rotation matrix
Rb=axa2R(rb);
%Ra=axang2rotm(ra); % convert axis-angle to rotation matrix (Matlab command)
%Rb=axang2rotm(rb);
R=Rb*Ra;
rc=R2axa(R); % convert rotation matrix to axis-angle
%rc=rotm2axang(R); % convert rotation matrix to axis-angle (Matlab command)
n=rc(1:3)'
ga=rc(4)
axa2R.m Copy
function R=axa2R(r)
n13=norm(r(1:3));
r(1:3)=r(1:3)/n13;
nx=r(1); ny=r(2); nz=r(3);
fi=r(4);
R=[ cos(fi)-nx^2*(cos(fi)-1), - nz*sin(fi) - nx*ny*(cos(fi) - 1), ny*sin(fi) - nx*nz*(cos(fi) - 1)
nz*sin(fi) - nx*ny*(cos(fi) - 1), cos(fi)-ny^2*(cos(fi)-1), - nx*sin(fi) - ny*nz*(cos(fi) - 1)
- ny*sin(fi) - nx*nz*(cos(fi) - 1), nx*sin(fi) - ny*nz*(cos(fi) - 1), cos(fi)-nz^2*(cos(fi)-1) ];
The function R2axa treats γ ≈ 0 \gamma\approx0 γ ≈ 0 , 0 < γ < π 0<\gamma<\pi 0 < γ < π and γ ≈ π \gamma\approx\pi γ ≈ π separately, clips the argument of acos to [ − 1 , 1 ] [-1,1] [ − 1 , 1 ] , and normalizes the recovered axis:
R2axa.m Copy
function r=R2axa(R)
%*** R2axa ***
% Convert an active rotation matrix to principal axis-angle form.
tol=1e-12;
c=(trace(R)-1)/2;
c=max(-1,min(1,c));
ga=acos(c);
w=[R(3,2)-R(2,3) R(1,3)-R(3,1) R(2,1)-R(1,2)]/2;
sn=norm(w);
if ga<1e-7
if sn<tol
r=[1 0 0 0];
return
end
ga=atan2(sn,c);
n=w/sn;
elseif pi-ga<1e-5
% Recover the axis without division by sin(ga).
A=(R+R'+2*eye(3))/4;
[~,k]=max(diag(A));
n=zeros(1,3);
n(k)=sqrt(max(A(k,k),0));
j=setdiff(1:3,k);
n(j)=A(j,k)'/n(k);
if dot(n,w)<0; n=-n; end
ga=atan2(sn,c);
else
n=w/sin(ga);
end
n=n/norm(n);
r=[n ga];
end
The result is: r c = [ 0.5766 0.0231 0.8167 1.3547 ] rc=\begin{bmatrix}0.5766&0.0231&0.8167&1.3547\end{bmatrix} r c = [ 0.5766 0.0231 0.8167 1.3547 ] , that is:
n = { 0.5766 0.0231 0.8167 } a n d γ = 1.3547 r a d \htmlClass{fea-math-bold-italic}{\boldsymbol n}=\begin{Bmatrix}0.5766\\0.0231\\0.8167\end{Bmatrix}\qquad\mathit{and}\qquad\gamma=1.3547\ \mathit{rad} n = ⎩ ⎨ ⎧ 0.5766 0.0231 0.8167 ⎭ ⎬ ⎫ and γ = 1.3547 rad
Using quaternions (run comp2):
comp2.m Copy
% comp2
al=pi/4;
l=[1 3 2]; l=l/norm(l);
qa=[cos(al/2) sin(al/2)*l]; % first quaternion
be=pi/3;
m=[2 -1 1]; m=m/norm(m);
qb=[cos(be/2) sin(be/2)*m]; % second quaternion
qc=quatmult(qb,qa); % quaternion multiplication
%qc=quatmultiply(qb,qa); % quaternion multiplication (Matlab command)
rc=quat2axa(qc); % convert quaternion to axis-angle
%rc=quat2axang(qc); % convert quaternion to axis-angle (Matlab command)
n=rc(1:3)'
ga=rc(4)
quatmult.m Copy
function qc=quatmult(qa,qb)
a0=qa(1); a1=qa(2); a2=qa(3); a3=qa(4);
b0=qb(1); b1=qb(2); b2=qb(3); b3=qb(4);
qc=[a0*b0-a1*b1-a2*b2-a3*b3
a0*b1+a1*b0+a2*b3-a3*b2
a0*b2-a1*b3+a2*b0+a3*b1
a0*b3+a1*b2-a2*b1+a3*b0];
The function quat2axa normalizes the quaternion and selects the sign with q 0 ≥ 0 q_0\ge0 q 0 ≥ 0 . It protects the argument of acos, treats zero rotation explicitly, and returns the principal angle 0 ≤ γ ≤ π 0\le\gamma\le\pi 0 ≤ γ ≤ π :
quat2axa.m Copy
function r=quat2axa(q)
%*** quat2axa ***
% Convert a scalar-first quaternion to principal axis-angle form.
tol=1e-12;
q=q(:)';
nq=norm(q);
if nq==0; error('The quaternion must be nonzero.'); end
q=q/nq;
if q(1)<0; q=-q; end
c=max(-1,min(1,q(1)));
ga=2*acos(c);
sn=norm(q(2:4));
if sn<tol
r=[1 0 0 0];
return
end
if ga<1e-7; ga=2*atan2(sn,c); end
n=q(2:4)/sn;
n=n/norm(n);
r=[n ga];
end
For γ = 0 \gamma=0 γ = 0 , the rotation axis is indeterminate; any unit vector represents the identity rotation. In the program, the conventional choice [ 1 0 0 ] [1\ 0\ 0] [ 1 0 0 ] is used.
06
References
Euler's rotation theorem. Composition of two axis-angle rotations. Quaternion. Quaternions and spatial rotation. Getting Euler–Tait–Bryan angles from quaternion representation. 1) Dot product and cross product of two vectors in matrix form:
a = { a x a y a z } a n d b = { b x b y b z } \htmlClass{fea-math-bold-italic}{\boldsymbol a}=\begin{Bmatrix}a_x\\a_y\\a_z\end{Bmatrix}\qquad\mathit{and}\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol b}=\begin{Bmatrix}b_x\\b_y\\b_z\end{Bmatrix} a = ⎩ ⎨ ⎧ a x a y a z ⎭ ⎬ ⎫ and b = ⎩ ⎨ ⎧ b x b y b z ⎭ ⎬ ⎫
a ⋅ b = a x b x + a y b y + a z b z a × b = [ 0 − a z a y a z 0 − a x − a y a x 0 ] { b x b y b z } \htmlClass{fea-math-bold-italic}{\boldsymbol a}\cdot\htmlClass{fea-math-bold-italic}{\boldsymbol b}=a_xb_x+a_yb_y+a_zb_z\qquad
\htmlClass{fea-math-bold-italic}{\boldsymbol a}\times\htmlClass{fea-math-bold-italic}{\boldsymbol b}=\begin{bmatrix}0&-a_z&a_y\\a_z&0&-a_x\\-a_y&a_x&0\end{bmatrix}\begin{Bmatrix}b_x\\b_y\\b_z\end{Bmatrix} a ⋅ b = a x b x + a y b y + a z b z a × b = 0 a z − a y − a z 0 a x a y − a x 0 ⎩ ⎨ ⎧ b x b y b z ⎭ ⎬ ⎫
PREVIOUS SECTION ← 21.2. Tait-Bryan angles NEXT SECTION 22.1. Curvature tensor of a 3D slender beam. Euler–Bernoulli beam theory →