Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:04:06

0001 #ifndef BOOST_QVM_QUAT_VEC_OPERATIONS_HPP_INCLUDED
0002 #define BOOST_QVM_QUAT_VEC_OPERATIONS_HPP_INCLUDED
0003 
0004 // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc.
0005 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #include <boost/qvm/quat_traits.hpp>
0009 #include <boost/qvm/deduce_vec.hpp>
0010 #include <boost/qvm/config.hpp>
0011 #include <boost/qvm/enable_if.hpp>
0012 
0013 namespace boost { namespace qvm {
0014 
0015 template <class A,class B>
0016 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
0017 typename lazy_enable_if_c<
0018     is_quat<A>::value &&
0019     is_vec<B>::value && vec_traits<B>::dim==3,
0020     deduce_vec2<A,B,3> >::type
0021 operator*( A const & a, B const & b )
0022     {
0023     typedef typename deduce_vec2<A,B,3>::type R;
0024     typedef typename quat_traits<A>::scalar_type TA;
0025     typedef typename vec_traits<B>::scalar_type TB;
0026     TA const aa = quat_traits<A>::template read_element<0>(a);
0027     TA const ab = quat_traits<A>::template read_element<1>(a);
0028     TA const ac = quat_traits<A>::template read_element<2>(a);
0029     TA const ad = quat_traits<A>::template read_element<3>(a);
0030     TA const t2 = aa*ab;
0031     TA const t3 = aa*ac;
0032     TA const t4 = aa*ad;
0033     TA const t5 = -ab*ab;
0034     TA const t6 = ab*ac;
0035     TA const t7 = ab*ad;
0036     TA const t8 = -ac*ac;
0037     TA const t9 = ac*ad;
0038     TA const t10     = -ad*ad;
0039     TB const bx = vec_traits<B>::template read_element<0>(b);
0040     TB const by = vec_traits<B>::template read_element<1>(b);
0041     TB const bz = vec_traits<B>::template read_element<2>(b);
0042     R r;
0043     write_vec_element<0>(r, 2*((t8+t10)*bx + (t6-t4)*by + (t3+t7)*bz) + bx);
0044     write_vec_element<1>(r, 2*((t4+t6)*bx + (t5+t10)*by + (t9-t2)*bz) + by);
0045     write_vec_element<2>(r, 2*((t7-t3)*bx + (t2+t9)*by + (t5+t8)*bz) + bz);
0046     return r;
0047     }
0048 
0049 namespace
0050 sfinae
0051     {
0052     using ::boost::qvm::operator*;
0053     }
0054 
0055 } }
0056 
0057 #endif