## Quaternions

 LA home Computing Maths  Glossary  Calculus  Stats  Series  N χ  Trig  Vectors  Matrices  Eigen v.  Ortho.  Least squares  Quaternions  Lagrange mult.  Quaternions also see AlgDS  Numerical   Superposition
The quaternions, devised by Hamilton (1843), generalize complex numbers.
H = {a 1 + b i + c j + d k | a,b,c,d ∈ R},   where i2 = j2 = k2 = ijk = -1,

from which it follows that

* 1 i j k
1 1 i j k
i i -1 k -j
j j -k -1 i
k k j -i -1
(note, non-commutative)
and
(a+bi+cj+dk) (A+Bi+Cj+Dk) = (aA-bB-cC-dD) + (aB+bA+cD-dC)i + (aC-bD+cA+dB)j + (aD+bC-cB+dA)k.

Suppose  q = a + bi + cj + dk;  q may also be written (a, b, c, d);  define
conjugate( q ) = q* = a - bi - cj - dk,
norm( q ) = ||q|| = √( q q* ) = √( a2 + b2 + c2 + d2 ),
inverse( q ) = q-1 = q* / ||q||2,

e.g.,

Note that
(p q)* = q* p*,
||p q|| = ||p|| ||q||,   and
(p q)-1 = q-1 p-1.

#### Vectors

A 3-D vector, v, can be mapped to, and from, a quaternion with zero real-part:
V2Q(<vx,vy,vz>) = (0,vx,vy,vz).

#### Rotations

The rotation of a 3-D vector, v, by angle, θ, about the axis specified by the unit vector, n, is

rotation(θ, n) =
let q = cos θ/2 + (nx sin θ/2) i + (ny sin θ/2) j + (nz sin θ/2) k
in function( v ) Q2V( q V2Q(v) q-1 )

This gives three degrees of freedom when choosing a rotation: θ, and <nx, ny, nz> subject to nx2 + ny2 + nz2 = 1.

e.g.,