Rotating a Cube Using Quaternions
Rotating a Cube Using Quaternions
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 ) and at any angle. This program uses the quaternion rotation formula: '=q with =0, (a pure quaternion), , and for a unit quaternion =, such that if , =(a,-b,-c,-d). A derivation of these formulas is given in [1].
u
1
p
1
p
1
-1
q
p
1
u
1
q=cos(α/2),sin(α/2)
u
1
-1
q
-
q
q=(a,b,c,d)
-
q