Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.


Quaternions are a relative of complex numbers.

Quaternions are in fact part of a small hierarchy of structures built upon the real numbers, which comprise only the set of real numbers (traditionally named R), the set of complex numbers (traditionally named C), the set of quaternions (traditionally named H) and the set of octonions (traditionally named O), which possess interesting mathematical properties (chief among which is the fact that they are division algebras, i.e. where the following property is true: if y is an element of that algebra and is not equal to zero, then yx = yx', where x and x' denote elements of that algebra, implies that x = x'). Each member of the hierarchy is a super-set of the former.

One of the most important aspects of quaternions is that they provide an efficient way to parameterize rotations in R3 (the usual three-dimensional space) and R4.

In practical terms, a quaternion is simply a quadruple of real numbers (α,β,γ,δ), which we can write in the form q = α + βi + γj + δk, where i is the same object as for complex numbers, and j and k are distinct objects which play essentially the same kind of role as i.

An addition and a multiplication is defined on the set of quaternions, which generalize their real and complex counterparts. The main novelty here is that the multiplication is not commutative (i.e. there are quaternions x and y such that xy ≠ yx). A good mnemotechnical way of remembering things is by using the formula i*i = j*j = k*k = -1.

Quaternions (and their kin) are described in far more details in this other document (with errata and addenda).

Some traditional constructs, such as the exponential, carry over without too much change into the realms of quaternions, but other, such as taking a square root, do not.