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 P = defaultp>
37 typedef tquat<T, P> 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<P>::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;
81 GLM_FUNC_DECL GLM_CONSTEXPR tquat(tquat<T, P> const& q) GLM_DEFAULT;
83 GLM_FUNC_DECL GLM_CONSTEXPR tquat(tquat<T, Q> const& q);
87 GLM_FUNC_DECL GLM_CONSTEXPR tquat(T s, vec<3, T, P> const& v);
88 GLM_FUNC_DECL GLM_CONSTEXPR tquat(T w, T x, T y, T z);
92 template<typename U, qualifier Q>
93 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tquat(tquat<U, Q> const& q);
96 # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
97 GLM_FUNC_DECL
explicit operator mat<3, 3, T, P>();
98 GLM_FUNC_DECL
explicit operator mat<4, 4, T, P>();
107 GLM_FUNC_DECL tquat(vec<3, T, P>
const & u, vec<3, T, P>
const & v);
110 GLM_FUNC_DECL GLM_EXPLICIT tquat(vec<3, T, P>
const&
eulerAngles);
111 GLM_FUNC_DECL GLM_EXPLICIT tquat(mat<3, 3, T, P>
const& q);
112 GLM_FUNC_DECL GLM_EXPLICIT tquat(mat<4, 4, T, P>
const& q);
116 GLM_FUNC_DECL tquat<T, P> & operator=(tquat<T, P>
const& q) GLM_DEFAULT;
119 GLM_FUNC_DECL tquat<T, P> & operator=(tquat<U, P>
const& q);
121 GLM_FUNC_DECL tquat<T, P> & operator+=(tquat<U, P>
const& q);
123 GLM_FUNC_DECL tquat<T, P> & operator-=(tquat<U, P>
const& q);
125 GLM_FUNC_DECL tquat<T, P> & operator*=(tquat<U, P>
const& q);
127 GLM_FUNC_DECL tquat<T, P> & operator*=(U s);
129 GLM_FUNC_DECL tquat<T, P> & operator/=(U s);
134 template<
typename T, qualifier P>
135 GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P>
const& q);
137 template<
typename T, qualifier P>
138 GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P>
const& q);
142 template<
typename T, qualifier P>
143 GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P>
const & q, tquat<T, P>
const & p);
145 template<
typename T, qualifier P>
146 GLM_FUNC_DECL tquat<T, P> operator*(tquat<T, P>
const & q, tquat<T, P>
const & p);
148 template<
typename T, qualifier P>
149 GLM_FUNC_DECL vec<3, T, P> operator*(tquat<T, P>
const & q, vec<3, T, P>
const & v);
151 template<
typename T, qualifier P>
152 GLM_FUNC_DECL vec<3, T, P> operator*(vec<3, T, P>
const & v, tquat<T, P>
const & q);
154 template<
typename T, qualifier P>
155 GLM_FUNC_DECL vec<4, T, P> operator*(tquat<T, P>
const & q, vec<4, T, P>
const & v);
157 template<
typename T, qualifier P>
158 GLM_FUNC_DECL vec<4, T, P> operator*(vec<4, T, P>
const & v, tquat<T, P>
const & q);
160 template<
typename T, qualifier P>
161 GLM_FUNC_DECL tquat<T, P> operator*(tquat<T, P>
const & q, T
const & s);
163 template<
typename T, qualifier P>
164 GLM_FUNC_DECL tquat<T, P> operator*(T
const & s, tquat<T, P>
const & q);
166 template<
typename T, qualifier P>
167 GLM_FUNC_DECL tquat<T, P> operator/(tquat<T, P>
const & q, T
const & s);
171 template<
typename T, qualifier P>
172 GLM_FUNC_DECL
bool operator==(tquat<T, P>
const & q1, tquat<T, P>
const & q2);
174 template<
typename T, qualifier P>
175 GLM_FUNC_DECL
bool operator!=(tquat<T, P>
const & q1, tquat<T, P>
const & q2);
182 template<
typename T, qualifier P>
183 GLM_FUNC_DECL T
length(tquat<T, P>
const & q);
190 template<
typename T, qualifier P>
191 GLM_FUNC_DECL tquat<T, P>
normalize(tquat<T, P>
const & q);
198 template<
typename T, qualifier P>
199 GLM_FUNC_DECL T
dot(tquat<T, P>
const & x, tquat<T, P>
const & y);
212 template<
typename T, qualifier P>
213 GLM_FUNC_DECL tquat<T, P>
mix(tquat<T, P>
const & x, tquat<T, P>
const & y, T a);
224 template<
typename T, qualifier P>
225 GLM_FUNC_DECL tquat<T, P>
lerp(tquat<T, P>
const & x, tquat<T, P>
const & y, T a);
236 template<
typename T, qualifier P>
237 GLM_FUNC_DECL tquat<T, P>
slerp(tquat<T, P>
const & x, tquat<T, P>
const & y, T a);
244 template<
typename T, qualifier P>
245 GLM_FUNC_DECL tquat<T, P>
conjugate(tquat<T, P>
const & q);
252 template<
typename T, qualifier P>
253 GLM_FUNC_DECL tquat<T, P>
inverse(tquat<T, P>
const & q);
263 template<
typename T, qualifier P>
264 GLM_FUNC_DECL tquat<T, P>
rotate(tquat<T, P>
const & q, T
const &
angle, vec<3, T, P>
const &
axis);
272 template<
typename T, qualifier P>
273 GLM_FUNC_DECL vec<3, T, P>
eulerAngles(tquat<T, P>
const & x);
280 template<
typename T, qualifier P>
281 GLM_FUNC_DECL T
roll(tquat<T, P>
const& x);
288 template<
typename T, qualifier P>
289 GLM_FUNC_DECL T
pitch(tquat<T, P>
const& x);
296 template<
typename T, qualifier P>
297 GLM_FUNC_DECL T
yaw(tquat<T, P>
const& x);
304 template<
typename T, qualifier P>
305 GLM_FUNC_DECL mat<3, 3, T, P>
mat3_cast(tquat<T, P>
const& x);
312 template<
typename T, qualifier P>
313 GLM_FUNC_DECL mat<4, 4, T, P>
mat4_cast(tquat<T, P>
const& x);
320 template<
typename T, qualifier P>
321 GLM_FUNC_DECL tquat<T, P>
quat_cast(mat<3, 3, T, P>
const& x);
328 template<
typename T, qualifier P>
329 GLM_FUNC_DECL tquat<T, P>
quat_cast(mat<4, 4, T, P>
const& x);
336 template<
typename T, qualifier P>
337 GLM_FUNC_DECL T
angle(tquat<T, P>
const& x);
344 template<
typename T, qualifier P>
345 GLM_FUNC_DECL vec<3, T, P>
axis(tquat<T, P>
const& x);
354 template<
typename T, qualifier P>
362 template<
typename T, qualifier P>
363 GLM_FUNC_DECL vec<4, bool, P>
lessThan(tquat<T, P>
const& x, tquat<T, P>
const& y);
370 template<
typename T, qualifier P>
371 GLM_FUNC_DECL vec<4, bool, P>
lessThanEqual(tquat<T, P>
const& x, tquat<T, P>
const& y);
378 template<
typename T, qualifier P>
379 GLM_FUNC_DECL vec<4, bool, P>
greaterThan(tquat<T, P>
const& x, tquat<T, P>
const& y);
386 template<
typename T, qualifier P>
387 GLM_FUNC_DECL vec<4, bool, P>
greaterThanEqual(tquat<T, P>
const& x, tquat<T, P>
const& y);
394 template<
typename T, qualifier P>
395 GLM_FUNC_DECL vec<4, bool, P>
equal(tquat<T, P>
const& x, tquat<T, P>
const& y);
402 template<
typename T, qualifier P>
403 GLM_FUNC_DECL vec<4, bool, P>
notEqual(tquat<T, P>
const& x, tquat<T, P>
const& y);
416 template<
typename T, qualifier P>
417 GLM_FUNC_DECL vec<4, bool, P>
isnan(tquat<T, P>
const& x);
428 template<
typename T, qualifier P>
429 GLM_FUNC_DECL vec<4, bool, P>
isinf(tquat<T, P>
const& x);
434 #include "quaternion.inl"
GLM_FUNC_DECL tquat< T, P > angleAxis(T const &angle, vec< 3, T, P > const &axis)
Build a quaternion from an angle and a normalized axis.
GLM_FUNC_DECL tquat< T, P > inverse(tquat< T, P > const &q)
Returns the q inverse.
GLM_FUNC_DECL T length(tquat< T, P > const &q)
Returns the length of the quaternion.
GLM_FUNC_DECL vec< 4, bool, P > greaterThanEqual(tquat< T, P > const &x, tquat< T, P > const &y)
Returns the component-wise comparison of result x >= y.
GLM_FUNC_DECL vec< 4, bool, P > lessThan(tquat< T, P > const &x, tquat< T, P > const &y)
Returns the component-wise comparison result of x < y.
GLM_FUNC_DECL tquat< T, P > mix(tquat< T, P > const &x, tquat< T, P > const &y, T a)
Spherical linear interpolation of two quaternions.
GLM_FUNC_DECL mat< 3, 3, T, P > mat3_cast(tquat< T, P > const &x)
Converts a quaternion to a 3 * 3 matrix.
GLM_FUNC_DECL T angle(tquat< T, P > const &x)
Returns the quaternion rotation angle.
GLM_FUNC_DECL vec< 4, bool, P > equal(tquat< T, P > const &x, tquat< T, P > const &y)
Returns the component-wise comparison of result x == y.
GLM_FUNC_DECL vec< 3, T, P > axis(tquat< T, P > const &x)
Returns the q rotation axis.
GLM_FUNC_DECL vec< 4, bool, P > notEqual(tquat< T, P > const &x, tquat< T, P > const &y)
Returns the component-wise comparison of result x != y.
GLM_FUNC_DECL tquat< T, P > normalize(tquat< T, P > const &q)
Returns the normalized quaternion.
GLM_FUNC_DECL vec< 4, bool, P > isinf(tquat< T, P > const &x)
Returns true if x holds a positive infinity or negative infinity representation in the underlying imp...
GLM_FUNC_DECL T pitch(tquat< T, P > const &x)
Returns pitch value of euler angles expressed in radians.
GLM_FUNC_DECL vec< 4, bool, P > isnan(tquat< T, P > const &x)
Returns true if x holds a NaN (not a number) representation in the underlying implementation's set of...
GLM_FUNC_DECL T roll(tquat< T, P > const &x)
Returns roll value of euler angles expressed in radians.
GLM_FUNC_DECL vec< 4, bool, P > lessThanEqual(tquat< T, P > const &x, tquat< T, P > const &y)
Returns the component-wise comparison of result x <= y.
GLM_FUNC_DECL tquat< T, P > quat_cast(mat< 4, 4, T, P > const &x)
Converts a 4 * 4 matrix to a quaternion.
GLM_FUNC_DECL vec< 3, T, P > eulerAngles(tquat< T, P > const &x)
Returns euler angles, pitch as x, yaw as y, roll as z.
GLM_FUNC_DECL vec< 4, bool, P > greaterThan(tquat< T, P > const &x, tquat< T, P > const &y)
Returns the component-wise comparison of result x > y.
GLM_FUNC_DECL mat< 4, 4, T, P > mat4_cast(tquat< T, P > const &x)
Converts a quaternion to a 4 * 4 matrix.
GLM_FUNC_DECL tquat< T, P > lerp(tquat< T, P > const &x, tquat< T, P > const &y, T a)
Linear interpolation of two quaternions.
GLM_FUNC_DECL tquat< T, P > conjugate(tquat< T, P > const &q)
Returns the q conjugate.
GLM_FUNC_DECL tquat< T, P > rotate(tquat< T, P > const &q, T const &angle, vec< 3, T, P > const &axis)
Rotates a quaternion from a vector of 3 components axis and an angle.
GLM_FUNC_DECL T dot(tquat< T, P > const &x, tquat< T, P > const &y)
Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
GLM_FUNC_DECL tquat< T, P > slerp(tquat< T, P > const &x, tquat< T, P > const &y, T a)
Spherical linear interpolation of two quaternions.
GLM_FUNC_DECL T yaw(tquat< T, P > const &x)
Returns yaw value of euler angles expressed in radians.