GLM: quaternion.hpp Source File

GLM 0.9.5

- Main Page
- Related Pages
- Modules
- Namespaces
- Files

- File List

gtc/quaternion.hpp
Go to the documentation of this file.
1
40 #ifndef GLM_GTC_quaternion
41 #define GLM_GTC_quaternion
42
43 // Dependency:
44 #include "../mat3x3.hpp"
45 #include "../mat4x4.hpp"
46 #include "../vec3.hpp"
47 #include "../vec4.hpp"
48 #include "../gtc/constants.hpp"
49
50 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
51 # pragma message("GLM: GLM_GTC_quaternion extension included")
52 #endif
53
54 namespace glm{
55 namespace detail
56 {
57 template <typename T, precision P>
58 struct tquat
59 {
60 enum ctor{null};
61
62 typedef tvec4<bool, P> bool_type;
63
64 public:
65 T x, y, z, w;
66
67 GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
68
69 // Constructors
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(
75 T const & s,
76 tvec3<T, P> const & v);
77 GLM_FUNC_DECL explicit tquat(
78 T const & w,
79 T const & x,
80 T const & y,
81 T const & z);
82
83 #if(GLM_HAS_INITIALIZER_LISTS)
84 template <typename U>
85 GLM_FUNC_DECL tquat(std::initializer_list<U> l);
86 #endif//GLM_HAS_INITIALIZER_LISTS
87
88 // Convertions
89
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(
101 tvec3<T, P> const & eulerAngles);
102 GLM_FUNC_DECL explicit tquat(
103 tmat3x3<T, P> const & m);
104 GLM_FUNC_DECL explicit tquat(
105 tmat4x4<T, P> const & m);
106
107 // Accesses
108 GLM_FUNC_DECL T & operator[](length_t i);
109 GLM_FUNC_DECL T const & operator[](length_t i) const;
110
111 // Operators
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);
116 };
117
118 template <typename T, precision P>
119 GLM_FUNC_DECL detail::tquat<T, P> operator- (
120 detail::tquat<T, P> const & q);
121
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);
126
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);
131
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);
136
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);
141
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);
146
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);
151
152 template <typename T, precision P>
153 GLM_FUNC_DECL detail::tquat<T, P> operator* (
154 detail::tquat<T, P> const & q,
155 T const & s);
156
157 template <typename T, precision P>
158 GLM_FUNC_DECL detail::tquat<T, P> operator* (
159 T const & s,
160 detail::tquat<T, P> const & q);
161
162 template <typename T, precision P>
163 GLM_FUNC_DECL detail::tquat<T, P> operator/ (
164 detail::tquat<T, P> const & q,
165 T const & s);
166
167 } //namespace detail
168
171
175 template <typename T, precision P>
176 GLM_FUNC_DECL T length(
177 detail::tquat<T, P> const & q);
178
182 template <typename T, precision P>
183 GLM_FUNC_DECL detail::tquat<T, P> normalize(
184 detail::tquat<T, P> const & q);
185
189 template <typename T, precision P, template <typename, precision> class quatType>
190 GLM_FUNC_DECL T dot(
191 quatType<T, P> const & x,
192 quatType<T, P> const & y);
193
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,
208 T const & a);
209
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,
222 T const & a);
223
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,
236 T const & a);
237
241 template <typename T, precision P>
242 GLM_FUNC_DECL detail::tquat<T, P> conjugate(
243 detail::tquat<T, P> const & q);
244
248 template <typename T, precision P>
249 GLM_FUNC_DECL detail::tquat<T, P> inverse(
250 detail::tquat<T, P> const & q);
251
259 template <typename T, precision P>
260 GLM_FUNC_DECL detail::tquat<T, P> rotate(
261 detail::tquat<T, P> const & q,
262 T const & angle,
263 detail::tvec3<T, P> const & axis);
264
269 template <typename T, precision P>
270 GLM_FUNC_DECL detail::tvec3<T, P> eulerAngles(
271 detail::tquat<T, P> const & x);
272
276 template <typename T, precision P>
277 GLM_FUNC_DECL T roll(detail::tquat<T, P> const & x);
278
282 template <typename T, precision P>
283 GLM_FUNC_DECL T pitch(detail::tquat<T, P> const & x);
284
288 template <typename T, precision P>
289 GLM_FUNC_DECL T yaw(detail::tquat<T, P> const & x);
290
294 template <typename T, precision P>
295 GLM_FUNC_DECL detail::tmat3x3<T, P> mat3_cast(
296 detail::tquat<T, P> const & x);
297
301 template <typename T, precision P>
302 GLM_FUNC_DECL detail::tmat4x4<T, P> mat4_cast(
303 detail::tquat<T, P> const & x);
304
308 template <typename T, precision P>
309 GLM_FUNC_DECL detail::tquat<T, P> quat_cast(
310 detail::tmat3x3<T, P> const & x);
311
315 template <typename T, precision P>
316 GLM_FUNC_DECL detail::tquat<T, P> quat_cast(
317 detail::tmat4x4<T, P> const & x);
318
322 template <typename T, precision P>
323 GLM_FUNC_DECL T angle(detail::tquat<T, P> const & x);
324
328 template <typename T, precision P>
329 GLM_FUNC_DECL detail::tvec3<T, P> axis(
330 detail::tquat<T, P> const & x);
331
338 template <typename T, precision P>
339 GLM_FUNC_DECL detail::tquat<T, P> angleAxis(
340 T const & angle,
341 detail::tvec3<T, P> const & axis);
342
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);
352
358 template <typename T, precision P>
359 GLM_FUNC_DECL detail::tvec4<bool, P> lessThanEqual(
360 detail::tquat<T, P> const & x,
361 detail::tquat<T, P> const & y);
362
368 template <typename T, precision P>
369 GLM_FUNC_DECL detail::tvec4<bool, P> greaterThan(
370 detail::tquat<T, P> const & x,
371 detail::tquat<T, P> const & y);
372
378 template <typename T, precision P>
379 GLM_FUNC_DECL detail::tvec4<bool, P> greaterThanEqual(
380 detail::tquat<T, P> const & x,
381 detail::tquat<T, P> const & y);
382
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);
392
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);
402
404 } //namespace glm
405
406 #include "quaternion.inl"
407
408 #endif//GLM_GTC_quaternion
glm::dot
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::notEqual
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::lerp
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::angleAxis
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::quat_cast
GLM_FUNC_DECL detail::tquat< T, P > quat_cast(detail::tmat3x3< T, P > const &x)
Converts a 3 * 3 matrix to a quaternion.
glm::rotate
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::mix
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::angle
GLM_FUNC_DECL T angle(detail::tquat< T, P > const &x)
Returns the quaternion rotation angle.
glm::eulerAngles
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::greaterThanEqual
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 &gt;= y.
glm::normalize
GLM_FUNC_DECL genType normalize(genType const &x)
Returns a vector in the same direction as x but with length of 1.
glm::mat4_cast
GLM_FUNC_DECL detail::tmat4x4< T, P > mat4_cast(detail::tquat< T, P > const &x)
Converts a quaternion to a 4 * 4 matrix.
glm::length
GLM_FUNC_DECL genType::value_type length(genType const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::roll
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::lessThan
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 &lt; y.
glm::mat3_cast
GLM_FUNC_DECL detail::tmat3x3< T, P > mat3_cast(detail::tquat< T, P > const &x)
Converts a quaternion to a 3 * 3 matrix.
glm::axis
GLM_FUNC_DECL detail::tvec3< T, P > axis(detail::tquat< T, P > const &x)
Returns the q rotation axis.
glm::equal
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::slerp
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.
Definition: compatibility.hpp:73
glm::pitch
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::conjugate
GLM_FUNC_DECL detail::tquat< T, P > conjugate(detail::tquat< T, P > const &q)
Returns the q conjugate.
glm::greaterThan
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 &gt; y.
glm::yaw
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::inverse
GLM_FUNC_DECL detail::tquat< T, P > inverse(detail::tquat< T, P > const &q)
Returns the q inverse.
glm::lessThanEqual
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 &lt; y.