Article 6X4C9 Composing rotations using quaternions

Composing rotations using quaternions

by
John
from John D. Cook on (#6X4C9)

Every rotation in 3D fixes an axis [1]. This is Euler's rotation theorem from 1775. Another way to state the theorem is that no matter how you rotate a sphere about its center, two points stay fixed.

The composition of two rotations is a rotation. So the first rotation fixes some axis, the second rotation fixes some axis, and the composition fixes some third axis. It's easy to see what these axes are if we work with quaternions. (Quaternions were discovered decades after Euler proved his rotation theorem.)

A rotation by about the axis given by a unit vector v = (v1, v2, v3) corresponds to the quaternion

q = (cos(/2), sin(/2)v1, sin(/2)v2, sin(/2)v3).

To rotate a pointp = (p1, p2, p3) by an angle about the axisv, first embedp as a quaternion by setting its first coordinate to 0:

p (0, p1, p2, p3)

and multiply the quaternionp on the left byq and on the right by the conjugate ofq, writtenq*. That is, the rotation takes p to

qpq*.

Becauseq has unit length [1], its conjugate is also its inverse: q* = q-1.

Composing rotations represented by quaternions is simple. Rotating by a quaterionsq and then by a quaterionr is the same as rotating by rq. Proof:

r(qpq*)r* = (rq)p(q*r*) = (rq)p(rq)*.

Here we use the property of quaternion conjugates that

(rq)* = q*r*.

See the next post for how to convert between quaternion and matrix representations of a rotation.

Related posts

[1] Note that this is not the case in two dimensions, nor is it true in higher even dimensions.

[2] We assumedv had unit length as a vector in ^3. So

||q||^2 = cos^2(/2) + sin^2(/2) = 1.

The post Composing rotations using quaternions first appeared on John D. Cook.
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments