# Quaternion

A *quaternion* is an operator that performs a rotation about the origin in 3D space. Conventionally, a quaternion $$\mathbf q$$ is written as

- $$\mathbf q = q_w + q_x \mathbf i + q_y \mathbf j + q_z \mathbf k$$ ,

where the "imaginary" units $$\mathbf i$$, $$\mathbf j$$, and $$\mathbf k$$ all square to $$-1$$ and multiply according to the rules

- $$\mathbf{ij} = -\mathbf{ji} = \mathbf k$$
- $$\mathbf{jk} = -\mathbf{kj} = \mathbf i$$
- $$\mathbf{ki} = -\mathbf{ik} = \mathbf j$$ .

A *unit quaternion* is one for which $$q_w^2 + q_x^2 + q_y^2 + q_z^2 = 1$$.

## Quaternions in 4D Rigid Geometric Algebra

Because quaternions keep the origin fixed, they are part of the group SO(3) where the special Euclidean group SE(3) and dual special Euclidean group DSE(3) intersect. Consequently, the quaternions have two different representations in the four-dimensional rigid geometric algebra $$\mathcal G_{3,0,1}$$.

### Quaternions as Motors

First, the quaternions are exactly the subset of motors that perform pure rotations about the origin without any translation. In this case, the units $$\mathbf i$$, $$\mathbf j$$, and $$\mathbf k$$ are identified as

- $$\mathbf i = \mathbf e_{41}$$
- $$\mathbf j = \mathbf e_{42}$$
- $$\mathbf k = \mathbf e_{43}$$ .

A quaternion can then be written as

- $$\mathbf q = q_x \mathbf e_{41} + q_y \mathbf e_{42} + q_z \mathbf e_{43} + q_w {\large\unicode{x1D7D9}}$$ ,

and any object $$\mathbf x$$ (such as a point, line, or plane) is rotated about the origin through the sandwich product

- $$\mathbf x' = \mathbf q \mathbin{\unicode{x27C7}} \mathbf x \mathbin{\unicode{x27C7}} \mathbf{\underset{\Large\unicode{x7E}}{q}}$$ ,

using the geometric antiproduct.

A unit quaternion can also be written as

- $$\mathbf q = \mathbf a \sin\phi + {\large\unicode{x1D7D9}}\cos\phi$$ ,

where $$\mathbf a = a_x \mathbf e_{41} + a_y \mathbf e_{42} + a_z \mathbf e_{43}$$ is a unit bivector representing the axis of rotation, and $$\phi$$ is half the angle of rotation.

### Quaternions as Dual Motors

Second, the quaternions are exactly the subset of dual motors for which the directrix lies in the horizon. In this case, the units $$\mathbf i$$, $$\mathbf j$$, and $$\mathbf k$$ are identified as

- $$\mathbf i = -\mathbf e_{23}$$
- $$\mathbf j = -\mathbf e_{31}$$
- $$\mathbf k = -\mathbf e_{12}$$ .

A quaternion can then be written as

- $$\mathbf q = -q_x \mathbf e_{23} - q_y \mathbf e_{31} - q_z \mathbf e_{12} + q_w \mathbf 1$$ ,

and any object $$\mathbf x$$ (such as a point, line, or plane) is rotated about the origin through the sandwich product

- $$\mathbf x' = \mathbf q \mathbin{\unicode{x27D1}} \mathbf x \mathbin{\unicode{x27D1}} \mathbf{\tilde q}$$ ,

using the geometric product.

A unit quaternion can also be written as

- $$\mathbf q = -\mathbf a \sin\phi + \mathbf 1\cos\phi$$ ,

where $$\mathbf a = a_x \mathbf e_{23} + a_y \mathbf e_{31} + a_z \mathbf e_{12}$$ is a unit bivector representing the axis of rotation, and $$\phi$$ is half the angle of rotation.