Quaternion Rotation and Its Inverse

1 Quaternion and Axis–Angle Representation

Let a unit quaternion be

q=[wxyz]=w+xi+yj+zk,w2+x2+y2+z2=1. q = \begin {bmatrix} w\\x\\y\\z \end {bmatrix} = w + xi + yj + zk, \qquad w^2+x^2+y^2+z^2=1.

Let the vector part be

v=[xyz]. \mathbf {v} = \begin {bmatrix} x\\y\\z \end {bmatrix}.

A rotation by angle θ\theta about the unit vector u^\hat {\mathbf {u}} can be represented by

q=[cos⁡(θ/2)u^sin⁡(θ/2)]. q = \begin {bmatrix} \cos (\theta /2)\\ \hat {\mathbf {u}}\sin (\theta /2) \end {bmatrix}.

That is,

q=(cos⁡θ2,u^sin⁡θ2). q = \left ( \cos \frac {\theta }{2}, \hat {\mathbf {u}}\sin \frac {\theta }{2} \right ).

2 Quaternion to Rotation Matrix

The rotation matrix corresponding to

q=(w,x,y,z) q=(w,x,y,z)

is

R(q)=[1−2(y2+z2)2(xy−zw)2(xz+yw)2(xy+zw)1−2(x2+z2)2(yz−xw)2(xz−yw)2(yz+xw)1−2(x2+y2)]. R(q)= \begin {bmatrix} 1-2(y^2+z^2) & 2(xy-zw) & 2(xz+yw)\\ 2(xy+zw) & 1-2(x^2+z^2) & 2(yz-xw)\\ 2(xz-yw) & 2(yz+xw) & 1-2(x^2+y^2) \end {bmatrix}.

Using the vector v\mathbf {v}, this can also be written as

R(q)=(w2−vTv)I+2vvT+2w[v]×, R(q) = (w^2-\mathbf {v}^{T}\mathbf {v})I +2\mathbf {v}\mathbf {v}^{T} +2w[\mathbf {v}]_\times ,

where

[v]×=[0−zyz0−x−yx0]. [\mathbf {v}]_\times = \begin {bmatrix} 0&-z&y\\ z&0&-x\\ -y&x&0 \end {bmatrix}.

3 Inverse of the Rotation Matrix

A rotation matrix is orthogonal, so

R−1=RT. R^{-1}=R^T.

Therefore,

R(q)−1=R(q)T. R(q)^{-1}=R(q)^T.

Taking the transpose gives

R(q)−1=[1−2(y2+z2)2(xy+zw)2(xz−yw)2(xy−zw)1−2(x2+z2)2(yz+xw)2(xz+yw)2(yz−xw)1−2(x2+y2)]. R(q)^{-1} = \begin {bmatrix} 1-2(y^2+z^2) & 2(xy+zw) & 2(xz-yw)\\ 2(xy-zw) & 1-2(x^2+z^2) & 2(yz+xw)\\ 2(xz+yw) & 2(yz-xw) & 1-2(x^2+y^2) \end {bmatrix}.

4 Quaternion Inverse

For a general quaternion,

q−1=q∗∥q∥2, q^{-1}=\frac {q^*}{\lVert q\rVert ^2},

where the quaternion conjugate is

q∗=w−xi−yj−zk. q^*=w-xi-yj-zk.

Therefore,

q−1=1w2+x2+y2+z2[w−x−y−z]. q^{-1} = \frac {1}{w^2+x^2+y^2+z^2} \begin {bmatrix} w\\-x\\-y\\-z \end {bmatrix}.

For a unit quaternion,

w2+x2+y2+z2=1, w^2+x^2+y^2+z^2=1,

so this simplifies to

q−1=q∗=[w−x−y−z]. \boxed { q^{-1}=q^*= \begin {bmatrix} w\\-x\\-y\\-z \end {bmatrix} }.

Consequently,

R(q)−1=R(q−1)=R(q∗). \boxed { R(q)^{-1}=R(q^{-1})=R(q^*) }.

In other words, to invert a unit-quaternion rotation, simply negate the vector part:

(w,x,y,z)−1=(w,−x,−y,−z). \boxed { (w,x,y,z)^{-1}=(w,-x,-y,-z) }.

5 Inverse Rotation: Reverse Axis or Negative Angle?

Suppose the original rotation is

q(u^,θ)=(cos⁡θ2,u^sin⁡θ2). q(\hat {\mathbf {u}},\theta ) = \left ( \cos \frac {\theta }{2}, \hat {\mathbf {u}}\sin \frac {\theta }{2} \right ).

Its inverse is

q−1=(cos⁡θ2,−u^sin⁡θ2). q^{-1} = \left ( \cos \frac {\theta }{2}, -\hat {\mathbf {u}}\sin \frac {\theta }{2} \right ).

There are two equivalent ways to interpret this inverse rotation.

5.1 Reverse the axis

Keep the angle positive:

q−1=(cos⁡θ2,(−u^)sin⁡θ2). q^{-1} = \left ( \cos \frac {\theta }{2}, (-\hat {\mathbf {u}})\sin \frac {\theta }{2} \right ).

Thus,

q−1=q(−u^,θ). \boxed { q^{-1}=q(-\hat {\mathbf {u}},\theta ) }.

This means: rotate by +θ+\theta about the opposite axis.

5.2 Use a negative angle

Keep the axis unchanged:

q(u^,−θ)=(cos⁡−θ2,u^sin⁡−θ2). q(\hat {\mathbf {u}},-\theta ) = \left ( \cos \frac {-\theta }{2}, \hat {\mathbf {u}}\sin \frac {-\theta }{2} \right ).

Since

cos⁡(−x)=cos⁡x,sin⁡(−x)=−sin⁡x, \cos (-x)=\cos x, \qquad \sin (-x)=-\sin x,

we obtain

q(u^,−θ)=(cos⁡θ2,−u^sin⁡θ2). q(\hat {\mathbf {u}},-\theta ) = \left ( \cos \frac {\theta }{2}, -\hat {\mathbf {u}}\sin \frac {\theta }{2} \right ).

Therefore,

q(u^,−θ)=q(−u^,θ). \boxed { q(\hat {\mathbf {u}},-\theta ) = q(-\hat {\mathbf {u}},\theta ) }.

The corresponding rotation matrices are also identical:

R(u^,−θ)=R(−u^,θ)=R(u^,θ)−1. \boxed { R(\hat {\mathbf {u}},-\theta ) = R(-\hat {\mathbf {u}},\theta ) = R(\hat {\mathbf {u}},\theta )^{-1} }.

6 Concrete Example

Consider a 90∘90^\circ rotation around the positive ZZ axis:

u^=[001],θ=90∘. \hat {\mathbf {u}}= \begin {bmatrix} 0\\0\\1 \end {bmatrix}, \qquad \theta =90^\circ .

The rotation matrix is

Rz(90∘)=[0−10100001]. R_z(90^\circ ) = \begin {bmatrix} 0&-1&0\\ 1&0&0\\ 0&0&1 \end {bmatrix}.

Its inverse is

Rz(90∘)−1=Rz(−90∘)=[010−100001]. R_z(90^\circ )^{-1} = R_z(-90^\circ ) = \begin {bmatrix} 0&1&0\\ -1&0&0\\ 0&0&1 \end {bmatrix}.

This can be interpreted either as

rotate −90∘ around +Z \boxed {\text {rotate }-90^\circ \text { around }+Z}

or

rotate +90∘ around −Z. \boxed {\text {rotate }+90^\circ \text { around }-Z}.

Both descriptions produce exactly the same rotation.

7 Key Result

For a unit quaternion,

q=(cos⁡θ2,u^sin⁡θ2) \boxed { q = \left ( \cos \frac {\theta }{2}, \hat {\mathbf {u}}\sin \frac {\theta }{2} \right ) }

and

q−1=(cos⁡θ2,−u^sin⁡θ2). \boxed { q^{-1} = \left ( \cos \frac {\theta }{2}, -\hat {\mathbf {u}}\sin \frac {\theta }{2} \right ) }.

Thus,

R(q)−1=R(q)T=R(q−1) \boxed { R(q)^{-1}=R(q)^T=R(q^{-1}) }

and the inverse rotation can be understood equivalently as

(u^,θ)⟶(u^,−θ) \boxed { (\hat {\mathbf {u}},\theta ) \longrightarrow (\hat {\mathbf {u}},-\theta ) }

or

(u^,θ)⟶(−u^,θ). \boxed { (\hat {\mathbf {u}},\theta ) \longrightarrow (-\hat {\mathbf {u}},\theta ) }.

The two axis–angle descriptions represent the same physical rotation.