QVM: Quaternions, Vectors, Matrices

Views

Boost QVM defines various function templates that provide static mapping between (possibly user-defined) quaternion, vector and matrix types. The example below multiplies column 1 (Boost QVM indexes are always zero-based) of the matrix m by a scalar:

void multiply_column1( float33 & m, float scalar )
{
    col<1>(m) *= scalar;
}

The expression col<1>(m) is a lvalue of an unspecified 3D vector type that refers to column 1 of m. Note however that this does not create any temporary objects; instead operator*= above works directly with a reference to m.

Here is another example, multiplying a transposed view of a matrix by a vector of some user-defined type float3:

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

In general, the various view functions return references of unspecified, non-copyable types that refer to the original object. They can be assigned from or converted to any compatible vector or matrix type.

For more details, see View Proxies.


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