File indexing completed on 2025-01-18 09:51:08
0001 #ifndef BOOST_QVM_QUAT_VEC_OPERATIONS_HPP_INCLUDED
0002 #define BOOST_QVM_QUAT_VEC_OPERATIONS_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009 #include <boost/qvm/quat_traits.hpp>
0010 #include <boost/qvm/deduce_vec.hpp>
0011 #include <boost/qvm/config.hpp>
0012 #include <boost/qvm/enable_if.hpp>
0013
0014 namespace boost { namespace qvm {
0015
0016 template <class A,class B>
0017 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
0018 typename lazy_enable_if_c<
0019 is_quat<A>::value &&
0020 is_vec<B>::value && vec_traits<B>::dim==3,
0021 deduce_vec2<A,B,3> >::type
0022 operator*( A const & a, B const & b )
0023 {
0024 typedef typename deduce_vec2<A,B,3>::type R;
0025 typedef typename quat_traits<A>::scalar_type TA;
0026 typedef typename vec_traits<B>::scalar_type TB;
0027 TA const aa = quat_traits<A>::template read_element<0>(a);
0028 TA const ab = quat_traits<A>::template read_element<1>(a);
0029 TA const ac = quat_traits<A>::template read_element<2>(a);
0030 TA const ad = quat_traits<A>::template read_element<3>(a);
0031 TA const t2 = aa*ab;
0032 TA const t3 = aa*ac;
0033 TA const t4 = aa*ad;
0034 TA const t5 = -ab*ab;
0035 TA const t6 = ab*ac;
0036 TA const t7 = ab*ad;
0037 TA const t8 = -ac*ac;
0038 TA const t9 = ac*ad;
0039 TA const t10 = -ad*ad;
0040 TB const bx = vec_traits<B>::template read_element<0>(b);
0041 TB const by = vec_traits<B>::template read_element<1>(b);
0042 TB const bz = vec_traits<B>::template read_element<2>(b);
0043 R r;
0044 write_vec_element<0>(r, 2*((t8+t10)*bx + (t6-t4)*by + (t3+t7)*bz) + bx);
0045 write_vec_element<1>(r, 2*((t4+t6)*bx + (t5+t10)*by + (t9-t2)*bz) + by);
0046 write_vec_element<2>(r, 2*((t7-t3)*bx + (t2+t9)*by + (t5+t8)*bz) + bz);
0047 return r;
0048 }
0049
0050 namespace
0051 sfinae
0052 {
0053 using ::boost::qvm::operator*;
0054 }
0055
0056 } }
0057
0058 #endif