FlukyEngine
quaternion.hpp
Go to the documentation of this file.
1 
14 #pragma once
15 
16 // Dependency:
17 #include "../glm.hpp"
18 #include "../gtc/constants.hpp"
19 #include "../gtc/quaternion.hpp"
20 #include "../ext/quaternion_exponential.hpp"
21 #include "../gtx/norm.hpp"
22 
23 #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
24 # ifndef GLM_ENABLE_EXPERIMENTAL
25 # pragma message("GLM: GLM_GTX_quaternion is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.")
26 # else
27 # pragma message("GLM: GLM_GTX_quaternion extension included")
28 # endif
29 #endif
30 
31 namespace glm
32 {
35 
39  template<typename T, qualifier Q>
40  GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> quat_identity();
41 
45  template<typename T, qualifier Q>
46  GLM_FUNC_DECL vec<3, T, Q> cross(
47  qua<T, Q> const& q,
48  vec<3, T, Q> const& v);
49 
53  template<typename T, qualifier Q>
54  GLM_FUNC_DECL vec<3, T, Q> cross(
55  vec<3, T, Q> const& v,
56  qua<T, Q> const& q);
57 
62  template<typename T, qualifier Q>
63  GLM_FUNC_DECL qua<T, Q> squad(
64  qua<T, Q> const& q1,
65  qua<T, Q> const& q2,
66  qua<T, Q> const& s1,
67  qua<T, Q> const& s2,
68  T const& h);
69 
73  template<typename T, qualifier Q>
74  GLM_FUNC_DECL qua<T, Q> intermediate(
75  qua<T, Q> const& prev,
76  qua<T, Q> const& curr,
77  qua<T, Q> const& next);
78 
82  //template<typename T, qualifier Q>
83  //qua<T, Q> sqrt(
84  // qua<T, Q> const& q);
85 
89  template<typename T, qualifier Q>
90  GLM_FUNC_DECL vec<3, T, Q> rotate(
91  qua<T, Q> const& q,
92  vec<3, T, Q> const& v);
93 
97  template<typename T, qualifier Q>
98  GLM_FUNC_DECL vec<4, T, Q> rotate(
99  qua<T, Q> const& q,
100  vec<4, T, Q> const& v);
101 
105  template<typename T, qualifier Q>
106  GLM_FUNC_DECL T extractRealComponent(
107  qua<T, Q> const& q);
108 
112  template<typename T, qualifier Q>
113  GLM_FUNC_DECL mat<3, 3, T, Q> toMat3(
114  qua<T, Q> const& x){return mat3_cast(x);}
115 
119  template<typename T, qualifier Q>
120  GLM_FUNC_DECL mat<4, 4, T, Q> toMat4(
121  qua<T, Q> const& x){return mat4_cast(x);}
122 
126  template<typename T, qualifier Q>
127  GLM_FUNC_DECL qua<T, Q> toQuat(
128  mat<3, 3, T, Q> const& x){return quat_cast(x);}
129 
133  template<typename T, qualifier Q>
134  GLM_FUNC_DECL qua<T, Q> toQuat(
135  mat<4, 4, T, Q> const& x){return quat_cast(x);}
136 
140  template<typename T, qualifier Q>
141  GLM_FUNC_DECL qua<T, Q> shortMix(
142  qua<T, Q> const& x,
143  qua<T, Q> const& y,
144  T const& a);
145 
149  template<typename T, qualifier Q>
150  GLM_FUNC_DECL qua<T, Q> fastMix(
151  qua<T, Q> const& x,
152  qua<T, Q> const& y,
153  T const& a);
154 
160  template<typename T, qualifier Q>
161  GLM_FUNC_DECL qua<T, Q> rotation(
162  vec<3, T, Q> const& orig,
163  vec<3, T, Q> const& dest);
164 
168  template<typename T, qualifier Q>
169  GLM_FUNC_DECL GLM_CONSTEXPR T length2(qua<T, Q> const& q);
170 
172 }//namespace glm
173 
174 #include "quaternion.inl"
GLM_FUNC_DECL GLM_CONSTEXPR qua< T, Q > quat_identity()
Create an identity quaternion.
Definition: quaternion.inl:9
Definition: type_vec3.hpp:17
Definition: qualifier.hpp:37
GLM_FUNC_DECL qua< T, Q > toQuat(mat< 3, 3, T, Q > const &x)
Converts a 3 * 3 matrix to a quaternion.
Definition: quaternion.hpp:127
Core features
Definition: common.hpp:20
Definition: type_mat3x3.hpp:13
GLM_FUNC_DECL mat< 4, 4, T, Q > rotate(mat< 4, 4, T, Q > const &m, T angle, vec< 3, T, Q > const &axis)
Builds a rotation 4 * 4 matrix created from an axis vector and an angle.
Definition: matrix_transform.inl:18
GLM_FUNC_DECL mat< 4, 4, T, Q > mat4_cast(qua< T, Q > const &x)
Converts a quaternion to a 4 * 4 matrix.
Definition: quaternion.inl:69
GLM_FUNC_DECL qua< T, Q > fastMix(qua< T, Q > const &x, qua< T, Q > const &y, T const &a)
Quaternion normalized linear interpolation.
Definition: quaternion.inl:116
GLM_FUNC_DECL mat< 3, 3, T, Q > toMat3(qua< T, Q > const &x)
Converts a quaternion to a 3 * 3 matrix.
Definition: quaternion.hpp:113
GLM_FUNC_DECL qua< T, Q > rotation(vec< 3, T, Q > const &orig, vec< 3, T, Q > const &dest)
Compute the rotation between two vectors.
Definition: quaternion.inl:122
GLM_FUNC_DECL T length2(vec< L, T, Q > const &x)
Returns the squared length of x.
Definition: norm.inl:26
Definition: type_mat4x4.hpp:13
GLM_FUNC_QUALIFIER vec< 3, T, Q > cross(vec< 3, T, Q > const &x, vec< 3, T, Q > const &y)
Returns the cross product of x and y.
Definition: func_geometric.inl:175
GLM_FUNC_DECL mat< 4, 4, T, Q > toMat4(qua< T, Q > const &x)
Converts a quaternion to a 4 * 4 matrix.
Definition: quaternion.hpp:120
GLM_FUNC_DECL T extractRealComponent(qua< T, Q > const &q)
Extract the real component of a quaternion.
Definition: quaternion.inl:63
GLM_FUNC_DECL qua< T, Q > quat_cast(mat< 3, 3, T, Q > const &x)
Converts a pure rotation 3 * 3 matrix to a quaternion.
Definition: quaternion.inl:75
GLM_FUNC_DECL qua< T, Q > squad(qua< T, Q > const &q1, qua< T, Q > const &q2, qua< T, Q > const &s1, qua< T, Q > const &s2, T const &h)
Compute a point on a path according squad equation.
Definition: quaternion.inl:28
GLM_FUNC_DECL qua< T, Q > shortMix(qua< T, Q > const &x, qua< T, Q > const &y, T const &a)
Quaternion interpolation using the rotation short path.
Definition: quaternion.inl:79
GLM_FUNC_DECL qua< T, Q > intermediate(qua< T, Q > const &prev, qua< T, Q > const &curr, qua< T, Q > const &next)
Returns an intermediate control point for squad interpolation.
Definition: quaternion.inl:40
GLM_FUNC_DECL mat< 3, 3, T, Q > mat3_cast(qua< T, Q > const &x)
Converts a quaternion to a 3 * 3 matrix.
Definition: quaternion.inl:41