WOLFRAM|DEMONSTRATIONS PROJECT

Rotating a Cube Using Quaternions

​
orientation of

u
1
(black vector)
θ
1
1.57
ϕ
1
0
rotating around

u
1
α
reset α
opacity
0.8
A quaternion can represent both a rotation axis and the angle of rotation about this axis (a vector and a scalar). Instead of turning an object through a series of successive rotations with rotation matrices, quaternions are used to rotate an object more smoothly around an arbitrary axis (here

u
1
) and at any angle. This program uses the quaternion rotation formula:
p
1
'=q
p
1
-1
q
with
p
1
=0,

u
1

(a pure quaternion),
q=cos(α/2),

u
1
sin(α/2)
, and for a unit quaternion
-1
q
=
-
q
, such that if
q=(a,b,c,d)
,
-
q
=(a,-b,-c,-d)
. A derivation of these formulas is given in [1].