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