40 #ifndef GLM_GTC_quaternion
41 #define GLM_GTC_quaternion
44 #include "../mat3x3.hpp"
45 #include "../mat4x4.hpp"
46 #include "../vec3.hpp"
47 #include "../vec4.hpp"
48 #include "../gtc/constants.hpp"
50 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
51 # pragma message("GLM: GLM_GTC_quaternion extension included")
57 template <
typename T, precision P>
62 typedef tvec4<bool, P> bool_type;
67 GLM_FUNC_DECL GLM_CONSTEXPR length_t
length()
const;
70 GLM_FUNC_DECL tquat();
71 template <
typename U, precision Q>
72 GLM_FUNC_DECL
explicit tquat(
73 tquat<U, Q>
const & q);
74 GLM_FUNC_DECL
explicit tquat(
76 tvec3<T, P>
const & v);
77 GLM_FUNC_DECL
explicit tquat(
83 #if(GLM_HAS_INITIALIZER_LISTS)
85 GLM_FUNC_DECL tquat(std::initializer_list<U> l);
86 #endif//GLM_HAS_INITIALIZER_LISTS
96 GLM_FUNC_DECL
explicit tquat(
97 detail::tvec3<T, P>
const & u,
98 detail::tvec3<T, P>
const & v);
100 GLM_FUNC_DECL
explicit tquat(
102 GLM_FUNC_DECL
explicit tquat(
103 tmat3x3<T, P>
const & m);
104 GLM_FUNC_DECL
explicit tquat(
105 tmat4x4<T, P>
const & m);
108 GLM_FUNC_DECL T & operator[](length_t i);
109 GLM_FUNC_DECL T
const & operator[](length_t i)
const;
112 GLM_FUNC_DECL tquat<T, P> & operator+=(tquat<T, P>
const & q);
113 GLM_FUNC_DECL tquat<T, P> & operator*=(tquat<T, P>
const & q);
114 GLM_FUNC_DECL tquat<T, P> & operator*=(T
const & s);
115 GLM_FUNC_DECL tquat<T, P> & operator/=(T
const & s);
118 template <
typename T, precision P>
119 GLM_FUNC_DECL detail::tquat<T, P> operator- (
120 detail::tquat<T, P>
const & q);
122 template <
typename T, precision P>
123 GLM_FUNC_DECL detail::tquat<T, P> operator+ (
124 detail::tquat<T, P>
const & q,
125 detail::tquat<T, P>
const & p);
127 template <
typename T, precision P>
128 GLM_FUNC_DECL detail::tquat<T, P> operator* (
129 detail::tquat<T, P>
const & q,
130 detail::tquat<T, P>
const & p);
132 template <
typename T, precision P>
133 GLM_FUNC_DECL detail::tvec3<T, P> operator* (
134 detail::tquat<T, P>
const & q,
135 detail::tvec3<T, P>
const & v);
137 template <
typename T, precision P>
138 GLM_FUNC_DECL detail::tvec3<T, P> operator* (
139 detail::tvec3<T, P>
const & v,
140 detail::tquat<T, P>
const & q);
142 template <
typename T, precision P>
143 GLM_FUNC_DECL detail::tvec4<T, P> operator* (
144 detail::tquat<T, P>
const & q,
145 detail::tvec4<T, P>
const & v);
147 template <
typename T, precision P>
148 GLM_FUNC_DECL detail::tvec4<T, P> operator* (
149 detail::tvec4<T, P>
const & v,
150 detail::tquat<T, P>
const & q);
152 template <
typename T, precision P>
153 GLM_FUNC_DECL detail::tquat<T, P> operator* (
154 detail::tquat<T, P>
const & q,
157 template <
typename T, precision P>
158 GLM_FUNC_DECL detail::tquat<T, P> operator* (
160 detail::tquat<T, P>
const & q);
162 template <
typename T, precision P>
163 GLM_FUNC_DECL detail::tquat<T, P> operator/ (
164 detail::tquat<T, P>
const & q,
175 template <
typename T, precision P>
177 detail::tquat<T, P>
const & q);
182 template <
typename T, precision P>
183 GLM_FUNC_DECL detail::tquat<T, P>
normalize(
184 detail::tquat<T, P>
const & q);
189 template <
typename T, precision P,
template <
typename, precision>
class quatType>
191 quatType<T, P>
const & x,
192 quatType<T, P>
const & y);
204 template <
typename T, precision P>
205 GLM_FUNC_DECL detail::tquat<T, P>
mix(
206 detail::tquat<T, P>
const & x,
207 detail::tquat<T, P>
const & y,
218 template <
typename T, precision P>
219 GLM_FUNC_DECL detail::tquat<T, P>
lerp(
220 detail::tquat<T, P>
const & x,
221 detail::tquat<T, P>
const & y,
232 template <
typename T, precision P>
233 GLM_FUNC_DECL detail::tquat<T, P>
slerp(
234 detail::tquat<T, P>
const & x,
235 detail::tquat<T, P>
const & y,
241 template <
typename T, precision P>
242 GLM_FUNC_DECL detail::tquat<T, P>
conjugate(
243 detail::tquat<T, P>
const & q);
248 template <
typename T, precision P>
249 GLM_FUNC_DECL detail::tquat<T, P>
inverse(
250 detail::tquat<T, P>
const & q);
259 template <
typename T, precision P>
260 GLM_FUNC_DECL detail::tquat<T, P>
rotate(
261 detail::tquat<T, P>
const & q,
263 detail::tvec3<T, P>
const &
axis);
269 template <
typename T, precision P>
271 detail::tquat<T, P>
const & x);
276 template <
typename T, precision P>
277 GLM_FUNC_DECL T
roll(detail::tquat<T, P>
const & x);
282 template <
typename T, precision P>
283 GLM_FUNC_DECL T
pitch(detail::tquat<T, P>
const & x);
288 template <
typename T, precision P>
289 GLM_FUNC_DECL T
yaw(detail::tquat<T, P>
const & x);
294 template <
typename T, precision P>
295 GLM_FUNC_DECL detail::tmat3x3<T, P>
mat3_cast(
296 detail::tquat<T, P>
const & x);
301 template <
typename T, precision P>
302 GLM_FUNC_DECL detail::tmat4x4<T, P>
mat4_cast(
303 detail::tquat<T, P>
const & x);
308 template <
typename T, precision P>
309 GLM_FUNC_DECL detail::tquat<T, P>
quat_cast(
310 detail::tmat3x3<T, P>
const & x);
315 template <
typename T, precision P>
316 GLM_FUNC_DECL detail::tquat<T, P>
quat_cast(
317 detail::tmat4x4<T, P>
const & x);
322 template <
typename T, precision P>
323 GLM_FUNC_DECL T
angle(detail::tquat<T, P>
const & x);
328 template <
typename T, precision P>
329 GLM_FUNC_DECL detail::tvec3<T, P>
axis(
330 detail::tquat<T, P>
const & x);
338 template <
typename T, precision P>
339 GLM_FUNC_DECL detail::tquat<T, P>
angleAxis(
341 detail::tvec3<T, P>
const &
axis);
348 template <
typename T, precision P>
349 GLM_FUNC_DECL detail::tvec4<bool, P>
lessThan(
350 detail::tquat<T, P>
const & x,
351 detail::tquat<T, P>
const & y);
358 template <
typename T, precision P>
360 detail::tquat<T, P>
const & x,
361 detail::tquat<T, P>
const & y);
368 template <
typename T, precision P>
370 detail::tquat<T, P>
const & x,
371 detail::tquat<T, P>
const & y);
378 template <
typename T, precision P>
380 detail::tquat<T, P>
const & x,
381 detail::tquat<T, P>
const & y);
388 template <
typename T, precision P>
389 GLM_FUNC_DECL detail::tvec4<bool, P>
equal(
390 detail::tquat<T, P>
const & x,
391 detail::tquat<T, P>
const & y);
398 template <
typename T, precision P>
399 GLM_FUNC_DECL detail::tvec4<bool, P>
notEqual(
400 detail::tquat<T, P>
const & x,
401 detail::tquat<T, P>
const & y);
406 #include "quaternion.inl"
408 #endif//GLM_GTC_quaternion
GLM_FUNC_DECL T dot(vecType< T, P > const &x, vecType< T, P > const &y)
Returns the dot product of x and y, i.e., result = x * y.
GLM_FUNC_DECL vecType< T, P >::bool_type notEqual(vecType< T, P > const &x, vecType< T, P > const &y)
Returns the component-wise comparison of result x == y.
GLM_FUNC_DECL detail::tquat< T, P > lerp(detail::tquat< T, P > const &x, detail::tquat< T, P > const &y, T const &a)
Linear interpolation of two quaternions.
GLM_FUNC_DECL detail::tquat< T, P > angleAxis(T const &angle, detail::tvec3< T, P > const &axis)
Build a quaternion from an angle and a normalized axis.
GLM_FUNC_DECL detail::tquat< T, P > quat_cast(detail::tmat3x3< T, P > const &x)
Converts a 3 * 3 matrix to a quaternion.
GLM_FUNC_DECL detail::tmat4x4< T, P > rotate(detail::tmat4x4< T, P > const &m, T const &angle, detail::tvec3< T, P > const &axis)
Builds a rotation 4 * 4 matrix created from an axis vector and an angle.
GLM_FUNC_DECL genTypeT mix(genTypeT const &x, genTypeT const &y, genTypeU const &a)
If genTypeU is a floating scalar or vector: Returns x * (1.0 - a) + y * a, i.e., the linear blend of ...
GLM_FUNC_DECL T angle(detail::tquat< T, P > const &x)
Returns the quaternion rotation angle.
GLM_FUNC_DECL detail::tvec3< T, P > eulerAngles(detail::tquat< T, P > const &x)
Returns euler angles, yitch as x, yaw as y, roll as z.
GLM_FUNC_DECL vecType< T, P >::bool_type greaterThanEqual(vecType< T, P > const &x, vecType< T, P > const &y)
Returns the component-wise comparison of result x >= y.
GLM_FUNC_DECL genType normalize(genType const &x)
Returns a vector in the same direction as x but with length of 1.
GLM_FUNC_DECL detail::tmat4x4< T, P > mat4_cast(detail::tquat< T, P > const &x)
Converts a quaternion to a 4 * 4 matrix.
GLM_FUNC_DECL genType::value_type length(genType const &x)
Returns the length of x, i.e., sqrt(x * x).
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
Returns roll value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees ot...
GLM_FUNC_DECL detail::tvec4< bool, P > lessThan(detail::tquat< T, P > const &x, detail::tquat< T, P > const &y)
Returns the component-wise comparison result of x < y.
GLM_FUNC_DECL detail::tmat3x3< T, P > mat3_cast(detail::tquat< T, P > const &x)
Converts a quaternion to a 3 * 3 matrix.
GLM_FUNC_DECL detail::tvec3< T, P > axis(detail::tquat< T, P > const &x)
Returns the q rotation axis.
GLM_FUNC_DECL detail::tvec4< bool, P > equal(detail::tquat< T, P > const &x, detail::tquat< T, P > const &y)
Returns the component-wise comparison of result x == y.
GLM_FUNC_DECL detail::tquat< T, P > slerp(detail::tquat< T, P > const &x, detail::tquat< T, P > const &y, T const &a)
Spherical linear interpolation of two quaternions.
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
Returns pitch value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees o...
GLM_FUNC_DECL detail::tquat< T, P > conjugate(detail::tquat< T, P > const &q)
Returns the q conjugate.
GLM_FUNC_DECL vecType< T, P >::bool_type greaterThan(vecType< T, P > const &x, vecType< T, P > const &y)
Returns the component-wise comparison of result x > y.
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
Returns yaw value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees oth...
GLM_FUNC_DECL detail::tquat< T, P > inverse(detail::tquat< T, P > const &q)
Returns the q inverse.
GLM_FUNC_DECL vecType< T, P >::bool_type lessThanEqual(vecType< T, P > const &x, vecType< T, P > const &y)
Returns the component-wise comparison result of x < y.