]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/qvm/quat_vec_operations.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / qvm / quat_vec_operations.hpp
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 UUID_51968952D30A11DFAFE78CE3DFD72085
7 #define UUID_51968952D30A11DFAFE78CE3DFD72085
8
9 #include <boost/qvm/quat_traits.hpp>
10 #include <boost/qvm/deduce_vec.hpp>
11 #include <boost/qvm/inline.hpp>
12 #include <boost/qvm/enable_if.hpp>
13
14 namespace
15 boost
16 {
17 namespace
18 qvm
19 {
20 template <class A,class B>
21 BOOST_QVM_INLINE_OPERATIONS
22 typename lazy_enable_if_c<
23 is_quat<A>::value &&
24 is_vec<B>::value && vec_traits<B>::dim==3,
25 deduce_vec2<A,B,3> >::type
26 operator*( A const & a, B const & b )
27 {
28 typedef typename deduce_vec2<A,B,3>::type R;
29 typedef typename quat_traits<A>::scalar_type TA;
30 typedef typename vec_traits<B>::scalar_type TB;
31 TA const aa = quat_traits<A>::template read_element<0>(a);
32 TA const ab = quat_traits<A>::template read_element<1>(a);
33 TA const ac = quat_traits<A>::template read_element<2>(a);
34 TA const ad = quat_traits<A>::template read_element<3>(a);
35 TA const t2 = aa*ab;
36 TA const t3 = aa*ac;
37 TA const t4 = aa*ad;
38 TA const t5 = -ab*ab;
39 TA const t6 = ab*ac;
40 TA const t7 = ab*ad;
41 TA const t8 = -ac*ac;
42 TA const t9 = ac*ad;
43 TA const t10 = -ad*ad;
44 TB const bx = vec_traits<B>::template read_element<0>(b);
45 TB const by = vec_traits<B>::template read_element<1>(b);
46 TB const bz = vec_traits<B>::template read_element<2>(b);
47 R r;
48 vec_traits<R>::template write_element<0>(r) = 2*((t8+t10)*bx + (t6-t4)*by + (t3+t7)*bz) + bx;
49 vec_traits<R>::template write_element<1>(r) = 2*((t4+t6)*bx + (t5+t10)*by + (t9-t2)*bz) + by;
50 vec_traits<R>::template write_element<2>(r) = 2*((t7-t3)*bx + (t2+t9)*by + (t5+t8)*bz) + bz;
51 return r;
52 }
53
54 namespace
55 sfinae
56 {
57 using ::boost::qvm::operator*;
58 }
59 }
60 }
61
62 #endif