QVM: Quaternions, Vectors, Matrices

quat

#include <boost/qvm/quat.hpp>

namespace boost
{
    namespace qvm
    {
        template <class T>
        struct quat
        {
            T a[4];
        
            template <class R>
            operator R() const
            {
                R r;
                assign(r,*this);
                return r;
            }
        };
        
        template <class Quaternion>
        struct quat_traits;
        
        template <class T>
        struct quat_traits< quat<T> >
        {
            typedef T scalar_type;
        
            template <int I> static scalar_type read_element( quat<T> const & x ) { return x.a[I]; }
            template <int I> static scalar_type & write_element( quat<T> & x ) { return x.a[I]; }
        };
    }
}

This is a simple quaternion type. It converts to any other quaternion type.

The partial specialization of the quat_traits template makes the quat template compatible with the generic operations defined by Boost QVM.


See also: boost/qvm/quat.hpp