FlukyEngine
type_quat.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 
6 // Dependency:
7 #include "../detail/type_mat3x3.hpp"
8 #include "../detail/type_mat4x4.hpp"
9 #include "../detail/type_vec3.hpp"
10 #include "../detail/type_vec4.hpp"
11 #include "../ext/vector_relational.hpp"
12 #include "../ext/quaternion_relational.hpp"
13 #include "../gtc/constants.hpp"
14 #include "../gtc/matrix_transform.hpp"
15 
16 namespace glm
17 {
18  template<typename T, qualifier Q>
19  struct qua
20  {
21  // -- Implementation detail --
22 
23  typedef qua<T, Q> type;
24  typedef T value_type;
25 
26  // -- Data --
27 
28 # if GLM_SILENT_WARNINGS == GLM_ENABLE
29 # if GLM_COMPILER & GLM_COMPILER_GCC
30 # pragma GCC diagnostic push
31 # pragma GCC diagnostic ignored "-Wpedantic"
32 # elif GLM_COMPILER & GLM_COMPILER_CLANG
33 # pragma clang diagnostic push
34 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
35 # pragma clang diagnostic ignored "-Wnested-anon-types"
36 # elif GLM_COMPILER & GLM_COMPILER_VC
37 # pragma warning(push)
38 # pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union
39 # endif
40 # endif
41 
42 # if GLM_LANG & GLM_LANG_CXXMS_FLAG
43  union
44  {
45 # ifdef GLM_FORCE_QUAT_DATA_WXYZ
46  struct { T w, x, y, z; };
47 # else
48  struct { T x, y, z, w; };
49 # endif
50 
51  typename detail::storage<4, T, detail::is_aligned<Q>::value>::type data;
52  };
53 # else
54 # ifdef GLM_FORCE_QUAT_DATA_WXYZ
55  T w, x, y, z;
56 # else
57  T x, y, z, w;
58 # endif
59 # endif
60 
61 # if GLM_SILENT_WARNINGS == GLM_ENABLE
62 # if GLM_COMPILER & GLM_COMPILER_CLANG
63 # pragma clang diagnostic pop
64 # elif GLM_COMPILER & GLM_COMPILER_GCC
65 # pragma GCC diagnostic pop
66 # elif GLM_COMPILER & GLM_COMPILER_VC
67 # pragma warning(pop)
68 # endif
69 # endif
70 
71  // -- Component accesses --
72 
73  typedef length_t length_type;
74 
76  GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 4;}
77 
78  GLM_FUNC_DECL GLM_CONSTEXPR T & operator[](length_type i);
79  GLM_FUNC_DECL GLM_CONSTEXPR T const& operator[](length_type i) const;
80 
81  // -- Implicit basic constructors --
82 
83  GLM_FUNC_DECL GLM_CONSTEXPR qua() GLM_DEFAULT;
84  GLM_FUNC_DECL GLM_CONSTEXPR qua(qua<T, Q> const& q) GLM_DEFAULT;
85  template<qualifier P>
86  GLM_FUNC_DECL GLM_CONSTEXPR qua(qua<T, P> const& q);
87 
88  // -- Explicit basic constructors --
89 
90  GLM_FUNC_DECL GLM_CONSTEXPR qua(T s, vec<3, T, Q> const& v);
91  GLM_FUNC_DECL GLM_CONSTEXPR qua(T w, T x, T y, T z);
92 
93  // -- Conversion constructors --
94 
95  template<typename U, qualifier P>
96  GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT qua(qua<U, P> const& q);
97 
99 # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
100  GLM_FUNC_DECL explicit operator mat<3, 3, T, Q>() const;
101  GLM_FUNC_DECL explicit operator mat<4, 4, T, Q>() const;
102 # endif
103 
110  GLM_FUNC_DECL qua(vec<3, T, Q> const& u, vec<3, T, Q> const& v);
111 
113  GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT qua(vec<3, T, Q> const& eulerAngles);
114  GLM_FUNC_DECL GLM_EXPLICIT qua(mat<3, 3, T, Q> const& q);
115  GLM_FUNC_DECL GLM_EXPLICIT qua(mat<4, 4, T, Q> const& q);
116 
117  // -- Unary arithmetic operators --
118 
119  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator=(qua<T, Q> const& q) GLM_DEFAULT;
120 
121  template<typename U>
122  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator=(qua<U, Q> const& q);
123  template<typename U>
124  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator+=(qua<U, Q> const& q);
125  template<typename U>
126  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator-=(qua<U, Q> const& q);
127  template<typename U>
128  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator*=(qua<U, Q> const& q);
129  template<typename U>
130  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator*=(U s);
131  template<typename U>
132  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator/=(U s);
133  };
134 
135  // -- Unary bit operators --
136 
137  template<typename T, qualifier Q>
138  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator+(qua<T, Q> const& q);
139 
140  template<typename T, qualifier Q>
141  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator-(qua<T, Q> const& q);
142 
143  // -- Binary operators --
144 
145  template<typename T, qualifier Q>
146  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator+(qua<T, Q> const& q, qua<T, Q> const& p);
147 
148  template<typename T, qualifier Q>
149  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator-(qua<T, Q> const& q, qua<T, Q> const& p);
150 
151  template<typename T, qualifier Q>
152  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator*(qua<T, Q> const& q, qua<T, Q> const& p);
153 
154  template<typename T, qualifier Q>
155  GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(qua<T, Q> const& q, vec<3, T, Q> const& v);
156 
157  template<typename T, qualifier Q>
158  GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v, qua<T, Q> const& q);
159 
160  template<typename T, qualifier Q>
161  GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(qua<T, Q> const& q, vec<4, T, Q> const& v);
162 
163  template<typename T, qualifier Q>
164  GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v, qua<T, Q> const& q);
165 
166  template<typename T, qualifier Q>
167  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator*(qua<T, Q> const& q, T const& s);
168 
169  template<typename T, qualifier Q>
170  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator*(T const& s, qua<T, Q> const& q);
171 
172  template<typename T, qualifier Q>
173  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator/(qua<T, Q> const& q, T const& s);
174 
175  // -- Boolean operators --
176 
177  template<typename T, qualifier Q>
178  GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(qua<T, Q> const& q1, qua<T, Q> const& q2);
179 
180  template<typename T, qualifier Q>
181  GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(qua<T, Q> const& q1, qua<T, Q> const& q2);
182 } //namespace glm
183 
184 #ifndef GLM_EXTERNAL_TEMPLATE
185 #include "type_quat.inl"
186 #endif//GLM_EXTERNAL_TEMPLATE
Definition: type_vec3.hpp:17
Definition: qualifier.hpp:37
static GLM_FUNC_DECL GLM_CONSTEXPR length_type length()
Return the count of components of a quaternion.
Definition: type_quat.hpp:76
Core features
Definition: common.hpp:20
Definition: type_mat3x3.hpp:13
Definition: type_vec4.hpp:17
Definition: type_mat4x4.hpp:13
GLM_FUNC_DECL vec< 3, T, Q > eulerAngles(qua< T, Q > const &x)
Returns euler angles, pitch as x, yaw as y, roll as z.
Definition: quaternion.inl:10