Boost C++ Libraries

...one 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.

QVM: Quaternions, Vectors, Matrices

boost/qvm/quat_traits_array.hpp

This header introduces specializations of the quat_traits, deduce_quat and deduce_quat2 templates that make it possible to pass C arrays of size 4 to any Boost QVM function that takes a quaternion.

For example, after #include <boost/qvm/quat_traits_array.hpp>, to compute the dot product of two float C arrays of size 4 interpreted as quaternions, you could use:

float a[4], b[4];
float dp = dot(a,b);

To use Boost QVM operator overloads, at least one of the arguments must not be of a built-in type; for example you can't multiply a C array quaternion by a scalar by using operator*= directly. Use qref to work around this issue:

float a[4];
qref(a) *= 42;

See also: ptr_qref