Quaternion Toolbox Overview

Quaternions

Quaternions are four-dimensional hypercomplex numbers (an extension of the complex number concept to higher dimensions). Conventionally, quaternions have four components and can be written in Cartesian form as:

q = w + xi + yj + zk
where the four 'coefficients' w, x, y, z are real or complex and the three hypercomplex operators i, j and k are square roots of -1 obeying the following rule: i^2 = j^2 = k^2 = ijk = -1.

.... to be expanded.

Toolbox design principles

Quaternions are represented by the toolbox with a private internal representation. Quaternion matrices are constructed by the constructor function quaternion which can combine together numeric matrices to make a full or pure quaternion. It is also possible to make a quaternion value by using the three quaternion 'operators', which are provided as parameterless functions qi, qj, qk:

3 .* qi + 4 .* qj
will yield the quaternion value 3i + 4j.

The toolbox has been designed to extend Matlab® in as natural a way as possible. Therefore the user should assume unless there is a reason to do otherwise that the way to carry out an operation is the same as in Matlab®. Where this is not the case, an error should occur. The documentation or the source code for the appropriate function should be consulted to see whether there is a known limitation.

For example, standard Matlab® notation has been overloaded for quaternion arrays, so that the following makes sense to the toolbox if the variables exist as quaternion arrays:

[p q r] * [a b c].'

Even if one of the vectors is replaced by a numeric vector, the result is still computable, since the toolbox can multiply numeric values by quaternions:

>> [1 2 3] * [qi qj qk].'
 
ans = 1 * I + 2 * J + 3 * K

Further, we can replace one element in the left vector by a quaternion, since the toolbox allows quaternion and numeric (non-quaternion) arrays to be concatenated: the numeric array is automatically converted to a quaternion array by putting the numeric values into the scalar part of an otherwise zero quaternion:

>> [1 qj 3] * [qi qj qk].'

ans =
 
     -1 + 1 * I + 0 * J + 3 * K
In most cases where quaternion matrices and vectors are handled it is not necessary to resort to 'tricks' to make things work: try the obvious first and if errors occur, work around them by explicit coding.

© 2008-2011 Stephen J. Sangwine and Nicolas Le Bihan.

License terms.