master
ブランチ master
VulkanExample / dep / include / glm / gtx / quaternion.hpp
4.7 KB、172行 生 Blame 履歴
1/// @ref gtx_quaternion
2/// @file glm/gtx/quaternion.hpp
3///
4/// @see core (dependence)
5/// @see gtx_extented_min_max (dependence)
6///
7/// @defgroup gtx_quaternion GLM_GTX_quaternion
8/// @ingroup gtx
9///
10/// Include <glm/gtx/quaternion.hpp> to use the features of this extension.
11///
12/// Extended quaternion types and functions
13
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#ifndef GLM_ENABLE_EXPERIMENTAL
24# error "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."
25#elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
26# pragma message("GLM: GLM_GTX_quaternion extension included")
27#endif
28
29namespace glm
30{
31 /// @addtogroup gtx_quaternion
32 /// @{
33
34 /// Create an identity quaternion.
35 ///
36 /// @see gtx_quaternion
37 template<typename T, qualifier Q>
38 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> quat_identity();
39
40 /// Compute a cross product between a quaternion and a vector.
41 ///
42 /// @see gtx_quaternion
43 template<typename T, qualifier Q>
44 GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> cross(
45 qua<T, Q> const& q,
46 vec<3, T, Q> const& v);
47
48 //! Compute a cross product between a vector and a quaternion.
49 ///
50 /// @see gtx_quaternion
51 template<typename T, qualifier Q>
52 GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> cross(
53 vec<3, T, Q> const& v,
54 qua<T, Q> const& q);
55
56 //! Compute a point on a path according squad equation.
57 //! q1 and q2 are control points; s1 and s2 are intermediate control points.
58 ///
59 /// @see gtx_quaternion
60 template<typename T, qualifier Q>
61 GLM_FUNC_DECL qua<T, Q> squad(
62 qua<T, Q> const& q1,
63 qua<T, Q> const& q2,
64 qua<T, Q> const& s1,
65 qua<T, Q> const& s2,
66 T const& h);
67
68 //! Returns an intermediate control point for squad interpolation.
69 ///
70 /// @see gtx_quaternion
71 template<typename T, qualifier Q>
72 GLM_FUNC_DECL qua<T, Q> intermediate(
73 qua<T, Q> const& prev,
74 qua<T, Q> const& curr,
75 qua<T, Q> const& next);
76
77 //! Returns quarternion square root.
78 ///
79 /// @see gtx_quaternion
80 //template<typename T, qualifier Q>
81 //qua<T, Q> sqrt(
82 // qua<T, Q> const& q);
83
84 //! Rotates a 3 components vector by a quaternion.
85 ///
86 /// @see gtx_quaternion
87 template<typename T, qualifier Q>
88 GLM_FUNC_DECL vec<3, T, Q> rotate(
89 qua<T, Q> const& q,
90 vec<3, T, Q> const& v);
91
92 /// Rotates a 4 components vector by a quaternion.
93 ///
94 /// @see gtx_quaternion
95 template<typename T, qualifier Q>
96 GLM_FUNC_DECL vec<4, T, Q> rotate(
97 qua<T, Q> const& q,
98 vec<4, T, Q> const& v);
99
100 /// Extract the real component of a quaternion.
101 ///
102 /// @see gtx_quaternion
103 template<typename T, qualifier Q>
104 GLM_FUNC_DECL T extractRealComponent(
105 qua<T, Q> const& q);
106
107 /// Converts a quaternion to a 3 * 3 matrix.
108 ///
109 /// @see gtx_quaternion
110 template<typename T, qualifier Q>
111 GLM_FUNC_QUALIFIER mat<3, 3, T, Q> toMat3(
112 qua<T, Q> const& x){return mat3_cast(x);}
113
114 /// Converts a quaternion to a 4 * 4 matrix.
115 ///
116 /// @see gtx_quaternion
117 template<typename T, qualifier Q>
118 GLM_FUNC_QUALIFIER mat<4, 4, T, Q> toMat4(
119 qua<T, Q> const& x){return mat4_cast(x);}
120
121 /// Converts a 3 * 3 matrix to a quaternion.
122 ///
123 /// @see gtx_quaternion
124 template<typename T, qualifier Q>
125 GLM_FUNC_QUALIFIER qua<T, Q> toQuat(
126 mat<3, 3, T, Q> const& x){return quat_cast(x);}
127
128 /// Converts a 4 * 4 matrix to a quaternion.
129 ///
130 /// @see gtx_quaternion
131 template<typename T, qualifier Q>
132 GLM_FUNC_QUALIFIER qua<T, Q> toQuat(
133 mat<4, 4, T, Q> const& x){return quat_cast(x);}
134
135 /// Quaternion interpolation using the rotation short path.
136 ///
137 /// @see gtx_quaternion
138 template<typename T, qualifier Q>
139 GLM_FUNC_DECL qua<T, Q> shortMix(
140 qua<T, Q> const& x,
141 qua<T, Q> const& y,
142 T const& a);
143
144 /// Quaternion normalized linear interpolation.
145 ///
146 /// @see gtx_quaternion
147 template<typename T, qualifier Q>
148 GLM_FUNC_DECL qua<T, Q> fastMix(
149 qua<T, Q> const& x,
150 qua<T, Q> const& y,
151 T const& a);
152
153 /// Compute the rotation between two vectors.
154 /// @param orig vector, needs to be normalized
155 /// @param dest vector, needs to be normalized
156 ///
157 /// @see gtx_quaternion
158 template<typename T, qualifier Q>
159 GLM_FUNC_DECL qua<T, Q> rotation(
160 vec<3, T, Q> const& orig,
161 vec<3, T, Q> const& dest);
162
163 /// Returns the squared length of x.
164 ///
165 /// @see gtx_quaternion
166 template<typename T, qualifier Q>
167 GLM_FUNC_DECL GLM_CONSTEXPR T length2(qua<T, Q> const& q);
168
169 /// @}
170}//namespace glm
171
172#include "quaternion.inl"