WOLFRAM|DEMONSTRATIONS PROJECT

Rotating a Unit Vector in 3D Using Quaternions

​
start position

u
1
(red)
θ
1
2π
3
ϕ
1
0
final position

u
2
(green)
θ
2
π
2
ϕ
2
2π
3
rotating

u
1
around OverscriptBox[\(\*SubscriptBox[\(u\), \(1\)]\( \)\), \(\)]​

u
2
(blue)

u
1
to

u
2
orbit
α
reset α
ImageSize
size
350
A quaternion is a vector in
4

with a noncommutative product (see [1] or Quaternion). Quaternions, also called hypercomplex numbers, were invented by William Rowan Hamilton in 1843. A quaternion can be written
q=w+xi+yj+zk
or, more compactly,
(w,x,y,z)
or
w,

r

, where the noncommuting unit quaternions obey the relations
2
i
=
2
j
=
2
k
=ijk=-1
.
A quaternion can represent a rotation axis, as well as a rotation about that axis. Instead of turning an object through a series of successive rotations using rotation matrices, quaternions can directly rotate an object around an arbitrary axis (here

u
1


u
2
) and at any angle
α
. This Demonstration uses the quaternion rotation formula
p
1
'=q
p
1
-1
q
with
p
1
=0,

u
1

, a pure quaternion (with real part zero),
q=cos
α
2
,

u
3
sin
α
2
, normalized axis

u
3
=

u
1


u
2


u
1
·

u
2
, and for a unit quaternion,
-1
q
=
-1
q
=
-
q
, where the quaternion conjugate for
p=(a,b,c,d)
is
-
p
=(a,-b,-c,-d)
.