File indexing completed on 2025-09-18 09:04:05
0001 #ifndef BOOST_QVM_QUAT_HPP_INCLUDED
0002 #define BOOST_QVM_QUAT_HPP_INCLUDED
0003
0004
0005
0006
0007
0008 #include <boost/qvm/detail/quat_assign.hpp>
0009 #include <boost/qvm/assert.hpp>
0010 #include <boost/qvm/static_assert.hpp>
0011
0012 namespace boost { namespace qvm {
0013
0014 template <class T>
0015 struct
0016 quat
0017 {
0018 T a[4];
0019 template <class R
0020 #if __cplusplus >= 201103L
0021 , class = typename enable_if<is_quat<R> >::type
0022 #endif
0023 >
0024 operator R() const
0025 {
0026 R r;
0027 assign(r,*this);
0028 return r;
0029 }
0030 };
0031
0032 template <class Q>
0033 struct quat_traits;
0034
0035 template <class T>
0036 struct
0037 quat_traits< quat<T> >
0038 {
0039 typedef quat<T> this_quaternion;
0040 typedef T scalar_type;
0041
0042 template <int I>
0043 static
0044 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0045 scalar_type
0046 read_element( this_quaternion const & x )
0047 {
0048 BOOST_QVM_STATIC_ASSERT(I>=0);
0049 BOOST_QVM_STATIC_ASSERT(I<4);
0050 return x.a[I];
0051 }
0052
0053 template <int I>
0054 static
0055 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0056 scalar_type &
0057 write_element( this_quaternion & x )
0058 {
0059 BOOST_QVM_STATIC_ASSERT(I>=0);
0060 BOOST_QVM_STATIC_ASSERT(I<4);
0061 return x.a[I];
0062 }
0063 };
0064
0065 } }
0066
0067 #endif