1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. 2 3 //Distributed under the Boost Software License, Version 1.0. (See accompanying 4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #ifndef BOOST_QVM_49C5A1042AEF11DF9603880056D89593 7 #define BOOST_QVM_49C5A1042AEF11DF9603880056D89593 8 9 #include <boost/qvm/detail/quat_assign.hpp> 10 #include <boost/qvm/assert.hpp> 11 #include <boost/qvm/static_assert.hpp> 12 13 namespace 14 boost 15 { 16 namespace 17 qvm 18 { 19 template <class T> 20 struct 21 quat 22 { 23 T a[4]; 24 template <class R> operator Rboost::qvm::quat25 operator R() const 26 { 27 R r; 28 assign(r,*this); 29 return r; 30 } 31 }; 32 33 template <class Q> 34 struct quat_traits; 35 36 template <class T> 37 struct 38 quat_traits< quat<T> > 39 { 40 typedef quat<T> this_quaternion; 41 typedef T scalar_type; 42 43 template <int I> 44 static 45 BOOST_QVM_INLINE_CRITICAL 46 scalar_type read_elementboost::qvm::quat_traits47 read_element( this_quaternion const & x ) 48 { 49 BOOST_QVM_STATIC_ASSERT(I>=0); 50 BOOST_QVM_STATIC_ASSERT(I<4); 51 return x.a[I]; 52 } 53 54 template <int I> 55 static 56 BOOST_QVM_INLINE_CRITICAL 57 scalar_type & write_elementboost::qvm::quat_traits58 write_element( this_quaternion & x ) 59 { 60 BOOST_QVM_STATIC_ASSERT(I>=0); 61 BOOST_QVM_STATIC_ASSERT(I<4); 62 return x.a[I]; 63 } 64 }; 65 } 66 } 67 68 #endif 69