1. The concept of quaternions

A quaternion can be thought of as an extension of a complex number and has three imaginary parts of the form:


q = w + x i + y j + z k o r q = s + v q=w+xi+yj+zk\quad or\quad q=s+v

Among them


i 2 = j 2 = k 2 = 1 i j = j i = k j k = j k = i k i = k i = j i^2=j^2=k^2=-1\\ ij=-ji=k\\ jk=-jk=i\\ ki=-ki=j\\

Common concepts of quaternions

1) Modulus of quaternion


q = w 2 + x 2 + y 2 + z 2 |q|=\sqrt{w^2+x^2+y^2+z^2}

2) Common quaternion operations


p 1 = [ s 1 . v 1 ] = ( w 1 . x 1 . y 1 . z 1 ) T p 2 = [ s 2 . v 2 ] = ( w 2 . x 2 . y 2 . z 2 ) T p_1=[s_1,\mathbf{v_1}]=(w_1,x_1,y_1,z_1)^T p_2=[s_2,\mathbf{v_2}]=(w_2,x_2,y_2,z_2)^T

– add


p 1 + p 2 = s 1 + s 2 . v 1 + v 2 = w 1 + w 2 + ( x 1 + x 2 ) i + ( y 1 + y 2 ) j + ( z 1 + z 2 ) k p_1+p_2=s_1+s_2,\mathbf{v_1+v_2}=w_1+w_2 + (x_1+x_2)i+(y_1+y_2)j+(z_1+z_2)k

– the multiplication


p 1 p 2 = s 1 s 2 v 1 v 2 + s 1 v 2 + s 2 v 1 + v 1 x v 2 = ( w 1 w 2 x 1 x 2 y 1 y 2 z 1 z 2 w 1 x 2 + x 1 w 2 + y 1 z 2 z 1 y 2 w 1 y 2 x 1 z 2 + y 1 w 2 + z 1 x 2 w 1 z 2 + x 2 y 2 y 1 x 2 + z 1 w 2 ) p_1p_2=s_1s_2-\mathbf{v_1v_2}+s_1\mathbf{v_2}+s_2\mathbf{v_1}+\mathbf{v1\times v2}\\ =\begin{pmatrix} w_1w_2 – x_1x_2 – y_1y_2 – z_1z_2 \\ w_1x_2 + x_1w_2 + y_1z_2 – z_1y_2 \\ w_1y_2 – x_1z_2 + y_1w_2 + z_1x_2 \\ w_1z_2 + x_2y_2 – y_1x_2 + z_1w_2\end{pmatrix}

– Dot product (inner product)


p 1 p 2 = w 1 w 2 + v 1 v 2 = w 1 w 2 + x 1 x 2 + y 1 y 2 + z 1 z 2 p_1\cdot p_2=w_1w_2+\mathbf{v_1v_2}=w_1w_2+x_1x_2+y_1y_2+z_1z_2

– Cross product (cross product)


p 1 x p 2 = p 1 p 2 p 2 p 2 2 = v 1 x v 2 p_1\times p_2=\frac{p_1p_2-p_2p_2}{2}=\mathbf{v1\times v2}

– conjugate


p 1 = s 1 v 1 p 1 p 1 = w 1 2 + x 1 2 + y 1 2 + z 1 2 p_1^*=s_1-\mathbf{v_1}\\ p_1p_1^*=w_1^2+x_1^2+y_1^2+z_1^2

Inverse –


p 1 1 = p 1 p 1 2 p 1 p 1 1 = p 1 1 p 1 = 1 p_1^{-1}=\frac{p_1^*}{\parallel p_1\parallel^2}\\ p_1p_1^{-1}=p_1^{-1}p_1=1

3) Unit quaternion

Satisfy the following formula,


w 2 + x 2 + y 2 + z 2 = 1 w^2+x^2+y^2+z^2=1

2. Quaternion and rigid rotation

Unit quaternion can be used to represent rotations in three dimensions. It is equivalent to the other two commonly used representations (three-dimensional orthogonal matrix and Euler Angle), but avoids the universal lock problem in euler Angle representation. The quaternion representation can give the rotation axis and rotation Angle more conveniently than the three dimensional orthogonal matrix representation. The rotation in three dimensions can be thought of as a functional ϕ\phiϕ a mapping of R3→R3\mathbb{R^3}\to\mathbb{R^3}R3→R3. If ϕ\phiϕ is to satisfy a rigid rotation it has to satisfy the following three points, plus PPP is a point in three-dimensional space that can be represented by a pure quaternion


P = [ 0 . v ] = x i + y j + z k P=[0,\mathbf{v}]=xi+yj+zk
  1. The length of the vector stays the same after rotation

ϕ ( P ) = P \parallel \phi(P) \parallel=\parallel P \parallel
  1. The Angle stays the same after rotation

ϕ ( P 1 ) ϕ ( P 2 ) = P 1 P 2 \phi(P_1) \cdot \phi(P_2) = P_1 \cdot P_2
  1. Handedness remains unchanged (i.e., the principle of right-handed coordinate system remains unchanged)

ϕ ( P 1 ) x ϕ ( P 2 ) = P 1 x P 2 \phi(P_1) \times \phi(P_2) = P_1 \times P_2

And ϕ (s + v) = s + ϕ (v) \ phi (s + \ mathbf {n}) = s + \ phi (\ mathbf {n}) ϕ (s + v) = s + ϕ (v), and because of PPP s = 0 s = 0 s = 0, so,


ϕ ( P 1 ) ϕ ( P 2 ) = ϕ ( P 1 P 2 ) \phi(P_1) \cdot \phi(P_2) =\phi(P_1P_2)

when


ϕ q ( P ) = q P q 1 \phi_q(P)=qPq^{-1}

When the above conditions are met, rigid rotation can be represented, where QQQ is unit quaternion. Substitute q=w+xi+yj+ ZKQ =w+xi+yj+ ZKQ =w+xi+yj+zk into the above equation to obtain the rotation matrix


R q = ( 1 2 y 2 2 z 2 2 x y 2 w z 2 x z + 2 w y 2 x y + 2 w z 1 2 x 2 2 z 2 2 y z 2 w x 2 x z 2 w y 2 y z + 2 w x 1 2 x 2 2 y 2 ) R_q= \begin{pmatrix} 1-2y^2-2z^2 & 2xy-2wz & 2xz+2wy \\ 2xy+2wz & 1-2x^2-2z^2 & 2yz-2wx \\ 2xz-2wy & 2yz+2wx & 1-2x^2-2y^2 \end{pmatrix}