17 #include "../mat3x3.hpp"
18 #include "../mat4x4.hpp"
19 #include "../vec3.hpp"
20 #include "../vec4.hpp"
21 #include "../gtc/constants.hpp"
23 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
24 # pragma message("GLM: GLM_GTC_quaternion extension included")
32 template<
typename T, qualifier Q = defaultp>
37 typedef tquat<T, Q> type;
42 # if GLM_HAS_ALIGNED_TYPE
43 # if GLM_COMPILER & GLM_COMPILER_GCC
44 # pragma GCC diagnostic push
45 # pragma GCC diagnostic ignored "-Wpedantic"
47 # if GLM_COMPILER & GLM_COMPILER_CLANG
48 # pragma clang diagnostic push
49 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
50 # pragma clang diagnostic ignored "-Wnested-anon-types"
55 struct { T x, y, z, w;};
56 typename detail::storage<T, sizeof(T) * 4, detail::is_aligned<Q>::value>::type data;
59 # if GLM_COMPILER & GLM_COMPILER_CLANG
60 # pragma clang diagnostic pop
62 # if GLM_COMPILER & GLM_COMPILER_GCC
63 # pragma GCC diagnostic pop
71 typedef length_t length_type;
73 GLM_FUNC_DECL
static GLM_CONSTEXPR length_type
length(){
return 4;}
75 GLM_FUNC_DECL T & operator[](length_type i);
76 GLM_FUNC_DECL T
const& operator[](length_type i)
const;
80 GLM_FUNC_DECL GLM_CONSTEXPR tquat() GLM_DEFAULT_CTOR;
81 GLM_FUNC_DECL GLM_CONSTEXPR tquat(tquat<T, Q> const& q) GLM_DEFAULT;
83 GLM_FUNC_DECL GLM_CONSTEXPR tquat(tquat<T, P> const& q);
87 GLM_FUNC_DECL GLM_CONSTEXPR tquat(T s, vec<3, T, Q> const& v);
88 GLM_FUNC_DECL GLM_CONSTEXPR tquat(T w, T x, T y, T z);
92 template<typename U, qualifier P>
93 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tquat(tquat<U, P> const& q);
96 # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
97 GLM_FUNC_DECL
explicit operator mat<3, 3, T, Q>();
98 GLM_FUNC_DECL
explicit operator mat<4, 4, T, Q>();
107 GLM_FUNC_DECL tquat(vec<3, T, Q>
const& u, vec<3, T, Q>
const& v);
110 GLM_FUNC_DECL GLM_EXPLICIT tquat(vec<3, T, Q>
const&
eulerAngles);
111 GLM_FUNC_DECL GLM_EXPLICIT tquat(mat<3, 3, T, Q>
const& q);
112 GLM_FUNC_DECL GLM_EXPLICIT tquat(mat<4, 4, T, Q>
const& q);
116 GLM_FUNC_DECL tquat<T, Q> & operator=(tquat<T, Q>
const& q) GLM_DEFAULT;
119 GLM_FUNC_DECL tquat<T, Q> & operator=(tquat<U, Q>
const& q);
121 GLM_FUNC_DECL tquat<T, Q> & operator+=(tquat<U, Q>
const& q);
123 GLM_FUNC_DECL tquat<T, Q> & operator-=(tquat<U, Q>
const& q);
125 GLM_FUNC_DECL tquat<T, Q> & operator*=(tquat<U, Q>
const& q);
127 GLM_FUNC_DECL tquat<T, Q> & operator*=(U s);
129 GLM_FUNC_DECL tquat<T, Q> & operator/=(U s);
134 template<
typename T, qualifier Q>
135 GLM_FUNC_DECL tquat<T, Q> operator+(tquat<T, Q>
const& q);
137 template<
typename T, qualifier Q>
138 GLM_FUNC_DECL tquat<T, Q> operator-(tquat<T, Q>
const& q);
142 template<
typename T, qualifier Q>
143 GLM_FUNC_DECL tquat<T, Q> operator+(tquat<T, Q>
const& q, tquat<T, Q>
const& p);
145 template<
typename T, qualifier Q>
146 GLM_FUNC_DECL tquat<T, Q> operator-(tquat<T, Q>
const& q, tquat<T, Q>
const& p);
148 template<
typename T, qualifier Q>
149 GLM_FUNC_DECL tquat<T, Q> operator*(tquat<T, Q>
const& q, tquat<T, Q>
const& p);
151 template<
typename T, qualifier Q>
152 GLM_FUNC_DECL vec<3, T, Q> operator*(tquat<T, Q>
const& q, vec<3, T, Q>
const& v);
154 template<
typename T, qualifier Q>
155 GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q>
const& v, tquat<T, Q>
const& q);
157 template<
typename T, qualifier Q>
158 GLM_FUNC_DECL vec<4, T, Q> operator*(tquat<T, Q>
const& q, vec<4, T, Q>
const& v);
160 template<
typename T, qualifier Q>
161 GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q>
const& v, tquat<T, Q>
const& q);
163 template<
typename T, qualifier Q>
164 GLM_FUNC_DECL tquat<T, Q> operator*(tquat<T, Q>
const& q, T
const& s);
166 template<
typename T, qualifier Q>
167 GLM_FUNC_DECL tquat<T, Q> operator*(T
const& s, tquat<T, Q>
const& q);
169 template<
typename T, qualifier Q>
170 GLM_FUNC_DECL tquat<T, Q> operator/(tquat<T, Q>
const& q, T
const& s);
174 template<
typename T, qualifier Q>
175 GLM_FUNC_DECL
bool operator==(tquat<T, Q>
const& q1, tquat<T, Q>
const& q2);
177 template<
typename T, qualifier Q>
178 GLM_FUNC_DECL
bool operator!=(tquat<T, Q>
const& q1, tquat<T, Q>
const& q2);
185 template<
typename T, qualifier Q>
186 GLM_FUNC_DECL T
length(tquat<T, Q>
const& q);
193 template<
typename T, qualifier Q>
194 GLM_FUNC_DECL tquat<T, Q>
normalize(tquat<T, Q>
const& q);
201 template<
typename T, qualifier Q>
202 GLM_FUNC_DECL T
dot(tquat<T, Q>
const& x, tquat<T, Q>
const& y);
215 template<
typename T, qualifier Q>
216 GLM_FUNC_DECL tquat<T, Q>
mix(tquat<T, Q>
const& x, tquat<T, Q>
const& y, T a);
227 template<
typename T, qualifier Q>
228 GLM_FUNC_DECL tquat<T, Q>
lerp(tquat<T, Q>
const& x, tquat<T, Q>
const& y, T a);
239 template<
typename T, qualifier Q>
240 GLM_FUNC_DECL tquat<T, Q>
slerp(tquat<T, Q>
const& x, tquat<T, Q>
const& y, T a);
247 template<
typename T, qualifier Q>
248 GLM_FUNC_DECL tquat<T, Q>
conjugate(tquat<T, Q>
const& q);
255 template<
typename T, qualifier Q>
256 GLM_FUNC_DECL tquat<T, Q>
inverse(tquat<T, Q>
const& q);
266 template<
typename T, qualifier Q>
267 GLM_FUNC_DECL tquat<T, Q>
rotate(tquat<T, Q>
const& q, T
const&
angle, vec<3, T, Q>
const&
axis);
275 template<
typename T, qualifier Q>
276 GLM_FUNC_DECL vec<3, T, Q>
eulerAngles(tquat<T, Q>
const& x);
283 template<
typename T, qualifier Q>
284 GLM_FUNC_DECL T
roll(tquat<T, Q>
const& x);
291 template<
typename T, qualifier Q>
292 GLM_FUNC_DECL T
pitch(tquat<T, Q>
const& x);
299 template<
typename T, qualifier Q>
300 GLM_FUNC_DECL T
yaw(tquat<T, Q>
const& x);
307 template<
typename T, qualifier Q>
308 GLM_FUNC_DECL mat<3, 3, T, Q>
mat3_cast(tquat<T, Q>
const& x);
315 template<
typename T, qualifier Q>
316 GLM_FUNC_DECL mat<4, 4, T, Q>
mat4_cast(tquat<T, Q>
const& x);
323 template<
typename T, qualifier Q>
324 GLM_FUNC_DECL tquat<T, Q>
quat_cast(mat<3, 3, T, Q>
const& x);
331 template<
typename T, qualifier Q>
332 GLM_FUNC_DECL tquat<T, Q>
quat_cast(mat<4, 4, T, Q>
const& x);
339 template<
typename T, qualifier Q>
340 GLM_FUNC_DECL T
angle(tquat<T, Q>
const& x);
347 template<
typename T, qualifier Q>
348 GLM_FUNC_DECL vec<3, T, Q>
axis(tquat<T, Q>
const& x);
357 template<
typename T, qualifier Q>
365 template<
typename T, qualifier Q>
366 GLM_FUNC_DECL vec<4, bool, Q>
lessThan(tquat<T, Q>
const& x, tquat<T, Q>
const& y);
373 template<
typename T, qualifier Q>
374 GLM_FUNC_DECL vec<4, bool, Q>
lessThanEqual(tquat<T, Q>
const& x, tquat<T, Q>
const& y);
381 template<
typename T, qualifier Q>
382 GLM_FUNC_DECL vec<4, bool, Q>
greaterThan(tquat<T, Q>
const& x, tquat<T, Q>
const& y);
389 template<
typename T, qualifier Q>
390 GLM_FUNC_DECL vec<4, bool, Q>
greaterThanEqual(tquat<T, Q>
const& x, tquat<T, Q>
const& y);
397 template<
typename T, qualifier Q>
398 GLM_FUNC_DECL vec<4, bool, Q>
equal(tquat<T, Q>
const& x, tquat<T, Q>
const& y);
405 template<
typename T, qualifier Q>
406 GLM_FUNC_DECL vec<4, bool, Q>
notEqual(tquat<T, Q>
const& x, tquat<T, Q>
const& y);
419 template<
typename T, qualifier Q>
420 GLM_FUNC_DECL vec<4, bool, Q>
isnan(tquat<T, Q>
const& x);
431 template<
typename T, qualifier Q>
432 GLM_FUNC_DECL vec<4, bool, Q>
isinf(tquat<T, Q>
const& x);
437 #include "quaternion.inl"
GLM_FUNC_DECL vec< 4, bool, Q > lessThan(tquat< T, Q > const &x, tquat< T, Q > const &y)
Returns the component-wise comparison result of x < y.
GLM_FUNC_DECL T angle(tquat< T, Q > const &x)
Returns the quaternion rotation angle.
GLM_FUNC_DECL tquat< T, Q > mix(tquat< T, Q > const &x, tquat< T, Q > const &y, T a)
Spherical linear interpolation of two quaternions.
GLM_FUNC_DECL vec< 4, bool, Q > isinf(tquat< T, Q > const &x)
Returns true if x holds a positive infinity or negative infinity representation in the underlying imp...
GLM_FUNC_DECL vec< 3, T, Q > axis(tquat< T, Q > const &x)
Returns the q rotation axis.
GLM_FUNC_DECL tquat< T, Q > conjugate(tquat< T, Q > const &q)
Returns the q conjugate.
GLM_FUNC_DECL T pitch(tquat< T, Q > const &x)
Returns pitch value of euler angles expressed in radians.
GLM_FUNC_DECL tquat< T, Q > rotate(tquat< T, Q > const &q, T const &angle, vec< 3, T, Q > const &axis)
Rotates a quaternion from a vector of 3 components axis and an angle.
GLM_FUNC_DECL T yaw(tquat< T, Q > const &x)
Returns yaw value of euler angles expressed in radians.
GLM_FUNC_DECL vec< 4, bool, Q > equal(tquat< T, Q > const &x, tquat< T, Q > const &y)
Returns the component-wise comparison of result x == y.
GLM_FUNC_DECL tquat< T, Q > quat_cast(mat< 4, 4, T, Q > const &x)
Converts a pure rotation 4 * 4 matrix to a quaternion.
GLM_FUNC_DECL vec< 3, T, Q > eulerAngles(tquat< T, Q > const &x)
Returns euler angles, pitch as x, yaw as y, roll as z.
GLM_FUNC_DECL T length(tquat< T, Q > const &q)
Returns the length of the quaternion.
GLM_FUNC_DECL vec< 4, bool, Q > lessThanEqual(tquat< T, Q > const &x, tquat< T, Q > const &y)
Returns the component-wise comparison of result x <= y.
GLM_FUNC_DECL T dot(tquat< T, Q > const &x, tquat< T, Q > const &y)
Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
GLM_FUNC_DECL vec< 4, bool, Q > notEqual(tquat< T, Q > const &x, tquat< T, Q > const &y)
Returns the component-wise comparison of result x != y.
GLM_FUNC_DECL mat< 3, 3, T, Q > mat3_cast(tquat< T, Q > const &x)
Converts a quaternion to a 3 * 3 matrix.
GLM_FUNC_DECL tquat< T, Q > slerp(tquat< T, Q > const &x, tquat< T, Q > const &y, T a)
Spherical linear interpolation of two quaternions.
GLM_FUNC_DECL vec< 4, bool, Q > isnan(tquat< T, Q > const &x)
Returns true if x holds a NaN (not a number) representation in the underlying implementation's set of...
GLM_FUNC_DECL tquat< T, Q > lerp(tquat< T, Q > const &x, tquat< T, Q > const &y, T a)
Linear interpolation of two quaternions.
GLM_FUNC_DECL T roll(tquat< T, Q > const &x)
Returns roll value of euler angles expressed in radians.
GLM_FUNC_DECL tquat< T, Q > inverse(tquat< T, Q > const &q)
Returns the q inverse.
GLM_FUNC_DECL tquat< T, Q > angleAxis(T const &angle, vec< 3, T, Q > const &axis)
Build a quaternion from an angle and a normalized axis.
GLM_FUNC_DECL tquat< T, Q > normalize(tquat< T, Q > const &q)
Returns the normalized quaternion.
GLM_FUNC_DECL vec< 4, bool, Q > greaterThanEqual(tquat< T, Q > const &x, tquat< T, Q > const &y)
Returns the component-wise comparison of result x >= y.
GLM_FUNC_DECL mat< 4, 4, T, Q > mat4_cast(tquat< T, Q > const &x)
Converts a quaternion to a 4 * 4 matrix.
GLM_FUNC_DECL vec< 4, bool, Q > greaterThan(tquat< T, Q > const &x, tquat< T, Q > const &y)
Returns the component-wise comparison of result x > y.