1
///////////////////////////////////////////////////////////////////////////////////
2
/// OpenGL Mathematics (glm.g-truc.net)
4
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6
/// of this software and associated documentation files (the "Software"), to deal
7
/// in the Software without restriction, including without limitation the rights
8
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
/// copies of the Software, and to permit persons to whom the Software is
10
/// furnished to do so, subject to the following conditions:
12
/// The above copyright notice and this permission notice shall be included in
13
/// all copies or substantial portions of the Software.
15
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
/// @ref gtx_quaternion
24
/// @file glm/gtx/quaternion.hpp
25
/// @date 2005-12-21 / 2011-06-07
26
/// @author Christophe Riccio
28
/// @see core (dependence)
29
/// @see gtx_extented_min_max (dependence)
31
/// @defgroup gtx_quaternion GLM_GTX_quaternion: Extented quaternion types and functions
34
/// @brief Extented quaternion types and functions
36
/// <glm/gtx/quaternion.hpp> need to be included to use these functionalities.
37
///////////////////////////////////////////////////////////////////////////////////
39
#ifndef GLM_GTX_quaternion
40
#define GLM_GTX_quaternion GLM_VERSION
44
#include "../gtc/quaternion.hpp"
46
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
47
# pragma message("GLM: GLM_GTX_quaternion extension included")
52
/// @addtogroup gtx_quaternion
55
//! Compute a cross product between a quaternion and a vector.
56
//! From GLM_GTX_quaternion extension.
57
template <typename valType>
58
detail::tvec3<valType> cross(
59
detail::tquat<valType> const & q,
60
detail::tvec3<valType> const & v);
62
//! Compute a cross product between a vector and a quaternion.
63
//! From GLM_GTX_quaternion extension.
64
template <typename valType>
65
detail::tvec3<valType> cross(
66
detail::tvec3<valType> const & v,
67
detail::tquat<valType> const & q);
69
//! Compute a point on a path according squad equation.
70
//! q1 and q2 are control points; s1 and s2 are intermediate control points.
71
//! From GLM_GTX_quaternion extension.
72
template <typename valType>
73
detail::tquat<valType> squad(
74
detail::tquat<valType> const & q1,
75
detail::tquat<valType> const & q2,
76
detail::tquat<valType> const & s1,
77
detail::tquat<valType> const & s2,
80
//! Returns an intermediate control point for squad interpolation.
81
//! From GLM_GTX_quaternion extension.
82
template <typename valType>
83
detail::tquat<valType> intermediate(
84
detail::tquat<valType> const & prev,
85
detail::tquat<valType> const & curr,
86
detail::tquat<valType> const & next);
88
//! Returns a exp of a quaternion.
89
//! From GLM_GTX_quaternion extension.
90
template <typename valType>
91
detail::tquat<valType> exp(
92
detail::tquat<valType> const & q,
93
valType const & exponent);
95
//! Returns a log of a quaternion.
96
//! From GLM_GTX_quaternion extension.
97
template <typename valType>
98
detail::tquat<valType> log(
99
detail::tquat<valType> const & q);
101
//! Returns x raised to the y power.
102
//! From GLM_GTX_quaternion extension.
103
template <typename valType>
104
detail::tquat<valType> pow(
105
detail::tquat<valType> const & x,
108
//! Returns quarternion square root.
109
//! From GLM_GTX_quaternion extension.
110
//template <typename valType>
111
//detail::tquat<valType> sqrt(
112
// detail::tquat<valType> const & q);
114
//! Rotates a 3 components vector by a quaternion.
115
//! From GLM_GTX_transform extension.
116
template <typename valType>
117
detail::tvec3<valType> rotate(
118
detail::tquat<valType> const & q,
119
detail::tvec3<valType> const & v);
121
//! Rotates a 4 components vector by a quaternion.
122
//! From GLM_GTX_transform extension.
123
template <typename valType>
124
detail::tvec4<valType> rotate(
125
detail::tquat<valType> const & q,
126
detail::tvec4<valType> const & v);
128
//! Returns the quaternion rotation angle.
129
//! From GLM_GTX_quaternion extension.
130
template <typename valType>
132
detail::tquat<valType> const & x);
134
//! Returns the q rotation axis.
135
//! From GLM_GTX_quaternion extension.
136
template <typename valType>
137
detail::tvec3<valType> axis(
138
detail::tquat<valType> const & x);
140
//! Build a quaternion from an angle and a normalized axis.
141
//! From GLM_GTX_quaternion extension.
142
template <typename valType>
143
detail::tquat<valType> angleAxis(
144
valType const & angle,
149
//! Build a quaternion from an angle and a normalized axis.
150
//! From GLM_GTX_quaternion extension.
151
template <typename valType>
152
detail::tquat<valType> angleAxis(
153
valType const & angle,
154
detail::tvec3<valType> const & axis);
156
//! Extract the real component of a quaternion.
157
//! From GLM_GTX_quaternion extension.
158
template <typename valType>
159
valType extractRealComponent(
160
detail::tquat<valType> const & q);
162
//! Returns roll value of euler angles in degrees.
163
//! From GLM_GTX_quaternion extension.
164
template <typename valType>
166
detail::tquat<valType> const & x);
168
//! Returns pitch value of euler angles in degrees.
169
//! From GLM_GTX_quaternion extension.
170
template <typename valType>
172
detail::tquat<valType> const & x);
174
//! Returns yaw value of euler angles in degrees.
175
//! From GLM_GTX_quaternion extension.
176
template <typename valType>
178
detail::tquat<valType> const & x);
180
//! Converts a quaternion to a 3 * 3 matrix.
181
//! From GLM_GTX_quaternion extension.
182
template <typename valType>
183
detail::tmat3x3<valType> toMat3(
184
detail::tquat<valType> const & x){return mat3_cast(x);}
186
//! Converts a quaternion to a 4 * 4 matrix.
187
//! From GLM_GTX_quaternion extension.
188
template <typename valType>
189
detail::tmat4x4<valType> toMat4(
190
detail::tquat<valType> const & x){return mat4_cast(x);}
192
//! Converts a 3 * 3 matrix to a quaternion.
193
//! From GLM_GTX_quaternion extension.
194
template <typename valType>
195
detail::tquat<valType> toQuat(
196
detail::tmat3x3<valType> const & x){return quat_cast(x);}
198
//! Converts a 4 * 4 matrix to a quaternion.
199
//! From GLM_GTX_quaternion extension.
200
template <typename valType>
201
detail::tquat<valType> toQuat(
202
detail::tmat4x4<valType> const & x){return quat_cast(x);}
204
//! Quaternion interpolation using the rotation short path.
205
//! From GLM_GTX_quaternion extension.
206
template <typename T>
207
detail::tquat<T> shortMix(
208
detail::tquat<T> const & x,
209
detail::tquat<T> const & y,
212
//! Quaternion normalized linear interpolation.
213
//! From GLM_GTX_quaternion extension.
214
template <typename T>
215
detail::tquat<T> fastMix(
216
detail::tquat<T> const & x,
217
detail::tquat<T> const & y,
223
#include "quaternion.inl"
225
#endif//GLM_GTX_quaternion