Content
    Basic Form

Quaternions

Quaternions are an extension to the real numbers. They have some similarities with Complex Numbers. The Quaternions are denoted with the symbol H \mathbb {H}.

Basic Form

x0+x1i+x2j+x3kx_0 + x_1 i + x_2 j + x_3 k

where 11, ii, jj and kk are the basis vectors (or basis elements).

Vector Representation

q=(s,v)=sv1,v2,v3q = (s, v) = s \langle v_1, v_2, v_3 \rangle

where:

  • s=x0s = x_0
  • v=(v1,v2,v3)=(x1,x2,x3)v = (v_1, v_2, v_3) = (x_1, x_2, x_3)

Matrix Representation

Complex Matrices
1=[1001]I=[i00i]J=[0110]K=[0ii0]\begin{align*} 1 &= \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ \end{bmatrix} \\ I &= \begin{bmatrix} i & 0 \\ 0 & -i \\ \end{bmatrix} \\ J &= \begin{bmatrix} 0 & 1 \\ -1 & 0 \\ \end{bmatrix} \\ K &= \begin{bmatrix} 0 & i \\ i & 0 \\ \end{bmatrix} \end{align*}
As Complex 2×22 \times 2 Matrix

Quaternion x0+x1i+x2j+x3kx_0 + x_1 i + x_2 j + x_3 k as complex C2×2\mathbb{C}^{2 \times 2} matrix:

[x0+x1ix2+x3ix2+x3ix0x1i]\begin{bmatrix} x_0 + x_1 i & x_2 + x_3 i \\ -x_2 + x_3 i & x_0 - x_1 i \end{bmatrix}
As Real 4×44 \times 4 Matrix

Quaternion x0+x1i+x2j+x3kx_0 + x_1 i + x_2 j + x_3 k as real R4×4\mathbb{R}^{4 \times 4} matrix:

[x0x1x3x2x1x0x2x3x3x2x0x1x2x3x1x0]\begin{bmatrix} x_0 & -x_1 & x_3 & -x_2 \\ x_1 & x_0 & -x_2 & -x_3 \\ -x_3 & x_2 & x_0 & -x_1 \\ x_2 & x_3 & x_1 & x_0 \end{bmatrix}

Addition

x+y=(x0+y0)+(x1+y1)i+(x2+y2)j+(x3+y3)kx+y = (x_{0}+y_{0})+(x_{1}+y_{1})\mathrm {i} +(x_{2}+y_{2})\mathrm {j} +(x_{3}+y_{3})\mathrm {k}

Addition is associative and commutative.

Multiplication

Basis Elements
i2=j2=k2=1ij=+k,jk=+i,ki=+jji=k,kj=i,ik=jijk=1\begin{align*} \mathrm {i} ^{2}=\mathrm {j} ^{2}=\mathrm {k} ^{2}=-1 \\ \mathrm {i} \mathrm {j} =+\mathrm {k} ,\quad \mathrm {j} \mathrm {k} =+\mathrm {i} ,\quad \mathrm {k} \mathrm {i} =+\mathrm {j} \\ \mathrm {j} \mathrm {i} =-\mathrm {k} ,\quad \mathrm {k} \mathrm {j} =-\mathrm {i} ,\quad \mathrm {i} \mathrm {k} =-\mathrm {j} \\ \mathrm {i} \mathrm {j} \mathrm {k} =-1 \end{align*}
Quaternion Multiplication (Hamilton Product)
q1q2=s1s2v1v2s1v2+s2v1+v1×v2q_1 \circ q_2 = s_1s_2 - v_1 \cdot v_2 \langle s_1 v_2 + s_2 v_1 + v_1 \times v_2 \rangle

Multiplication is associative but not commutative (xyyxxy \neq yx).

Inner Product
q1q2=s1s2+vx1vx2+vy1vy2+vz1vz2Hq_1 \cdot q_2 = s_1 s_2 + v_{x1} v_{x2} + v_{y1} v_{y2} + v_{z1} v_{z2} \in \mathbb{H}

Conjugation

xˉ=x0x1ix2jx3k {\bar {x}} =x_{0}-x_{1}\mathrm {i} -x_{2}\mathrm {j} -x_{3}\mathrm {k}

Norm

q=qqˉ=qˉq=a2+b2+c2+d2\lVert q\rVert ={\sqrt {q\bar{q}}}={\sqrt {\bar{q}q}}={\sqrt {a^{2}+b^{2}+c^{2}+d^{2}}}

Unit Quaternion

A unit Quaternion has the length (norm) of 11. It’s also called versor.

Uq=qq=1U_q = \frac{q}{\lVert q\rVert} = 1

Rotation

Unit quaternions can be used to represent rotations of an angle Θ\Theta around a unit vector v^\hat{v}.

Uq=cosΘ2v^sinΘ2S3U_q = \cos \frac{\Theta}{2} \langle \hat{v} \sin \frac{\Theta}{2} \rangle \in S^3

Note: UqU_q amd Uq-U_q represent the same rotation.

Rotation Matrix
q=(q0q1q2q3)=(cosθ2ω^sinθ2)R4q = \begin{pmatrix}q_0\\q_1\\q_2\\q_3\end{pmatrix} = \begin{pmatrix} \cos \frac{\theta}{2} \\ \hat{\omega} \sin \frac{\theta}{2}\end{pmatrix} \in {\mathbb{R}}^4

with:

  • q=1\lVert q\rVert = 1: Unit Quaternion (therefore only 3 degrees of freedom)

Note:

  • q0q_0 corresponds to cosθ2\cos \frac{\theta}{2}
  • (q1q2q3)\begin{pmatrix}q_1\\q_2\\q_3\end{pmatrix} corresponds to ω^sinθ2\hat{\omega} \sin \frac{\theta}{2}
From Rotation Matrix to Quaternion

Given the rotation matrix:

R=(r11r12r13r21r22r23r31r32r33)R = \begin{pmatrix}r_{11} & r_{12} & r_{13}\\r_{21} & r_{22} & r_{23} \\r_{31} & r_{32} & r_{33}\end{pmatrix}

Calculate the Quaternion:

q0=cosθ2=121+r11+r22+r33q_{0} = \cos \frac{\theta}{2} = \frac{1}{2} \sqrt {1+r_{11}+r_{22}+r_{33}}

and

(q1q2q3)=ω^sinθ2=14q0(r32r23r13r31r21r12)\begin{pmatrix}q_1\\q_2\\q_3\end{pmatrix} = \hat{\omega} \sin \frac{\theta}{2} = \frac{1}{4 q_0} \begin{pmatrix}r_{32}-r_{23}\\r_{13}-r_{31}\\r_{21}-r_{12}\end{pmatrix}
From Quaternion to Rotation Matrix
R=(q02+q12q22q322(q1q2q0q3)2(q0q2+q1q3)2(q0q3+q1q2)q02q12+q22q322(q2q3q0q1)2(q1q3q0q2)2(q0q1+q2q3)q02q12q22+q32)R = \begin{pmatrix}{q_{0}}^2 + {q_{1}}^2 - {q_{2}}^2 - {q_{3}}^2 & 2(q_{1}q_{2}-q_{0}q_{3}) & 2(q_{0}q_{2}+q_{1}q_{3})\\2(q_{0}q_{3}+q_{1}q_{2}) & {q_{0}}^2 - {q_{1}}^2 + {q_{2}}^2 - {q_{3}}^2 & 2(q_{2}q_{3}-q_{0}q_{1})\\2(q_{1}q_{3}-q_{0}q_{2}) & 2(q_{0}q_{1}+q_{2}q_{3}) & {q_{0}}^2 - {q_{1}}^2 - {q_{2}}^2 + {q_{3}}^2\end{pmatrix}


  • Category

  • Mathematics

  • Tags

  • Robotics

  • Created

  • 25. August 2025


  • Modified

  • 29. August 2025