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 to view this page for the latest version.

QVM: Quaternions, Vectors, Matrices

C Arrays

In boost/qvm/quat_traits_array.hpp, boost/qvm/vec_traits_array.hpp and boost/qvm/mat_traits_array.hpp Boost QVM defines appropriate quat_traits, vec_traits and mat_traits specializations that allow Boost QVM functions to operate directly on plain old C arrays:

float v[3] = {0,0,7};
float3 vrot = rotx_mat<3>(3.14159f) * v;

Naturally, operator overloads cannot kick in if all elements of an expression are of built-in types. The following is illegal:

float v[3] = {0,0,7};
v *= 42;

The vref and mref function templates can be used to work around this issue:

float v[3] = {0,0,7};
vref(v) *= 42;

Tutorial navigation: Quaternions, Vectors, Matrices | C Arrays | Views | Swizzling | Interoperability 
 
See also: Boost QVM