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