| 0.9.7

- Main Page
- Modules
- Files

- File List

simd_quat.hpp
Go to the documentation of this file.
1
42 #pragma once
43
44 // Dependency:
45 #include "../glm.hpp"
46 #include "../gtc/quaternion.hpp"
47 #include "../gtx/fast_trigonometry.hpp"
48
49 #if(GLM_ARCH != GLM_ARCH_PURE)
50
51 #if(GLM_ARCH & GLM_ARCH_SSE2)
52 # include "../gtx/simd_mat4.hpp"
53 #else
54 # error "GLM: GLM_GTX_simd_quat requires compiler support of SSE2 through intrinsics"
55 #endif
56
57 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
58 # pragma message("GLM: GLM_GTX_simd_quat extension included")
59 #endif
60
61 // Warning silencer for nameless struct/union.
62 #if (GLM_COMPILER & GLM_COMPILER_VC)
63 # pragma warning(push)
64 # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
65 #endif
66
67 namespace glm{
68 namespace detail
69 {
70 GLM_ALIGNED_STRUCT(16) fquatSIMD
71 {
72 typedef float value_type;
73 typedef std::size_t size_type;
74
75 typedef fquatSIMD type;
76 typedef tquat<bool, defaultp> bool_type;
77 typedef tquat<float, defaultp> pure_type;
78
79 # ifdef GLM_META_PROG_HELPERS
80 static GLM_RELAXED_CONSTEXPR length_t components = 4;
81 static GLM_RELAXED_CONSTEXPR precision prec = defaultp;
82 # endif//GLM_META_PROG_HELPERS
83
84 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
85 union
86 {
87 __m128 Data;
88 struct {float x, y, z, w;};
89 };
90 #else
91 __m128 Data;
92 #endif
93
95 // Implicit basic constructors
96
97 fquatSIMD() GLM_DEFAULT_CTOR;
98 fquatSIMD(fquatSIMD const & q) GLM_DEFAULT;
99 fquatSIMD(__m128 const & Data);
100
102 // Explicit basic constructors
103
104 explicit fquatSIMD(
105 ctor);
106 explicit fquatSIMD(
107 float const & w,
108 float const & x,
109 float const & y,
110 float const & z);
111 explicit fquatSIMD(
112 quat const & v);
113 explicit fquatSIMD(
114 vec3 const & eulerAngles);
115
116
118 // Unary arithmetic operators
119
120 fquatSIMD& operator= (fquatSIMD const & q) GLM_DEFAULT;
121 fquatSIMD& operator*=(float const & s);
122 fquatSIMD& operator/=(float const & s);
123 };
124
125
127 // Arithmetic operators
128
129 detail::fquatSIMD operator- (
130 detail::fquatSIMD const & q);
131
132 detail::fquatSIMD operator+ (
133 detail::fquatSIMD const & q,
134 detail::fquatSIMD const & p);
135
136 detail::fquatSIMD operator* (
137 detail::fquatSIMD const & q,
138 detail::fquatSIMD const & p);
139
140 detail::fvec4SIMD operator* (
141 detail::fquatSIMD const & q,
142 detail::fvec4SIMD const & v);
143
144 detail::fvec4SIMD operator* (
145 detail::fvec4SIMD const & v,
146 detail::fquatSIMD const & q);
147
148 detail::fquatSIMD operator* (
149 detail::fquatSIMD const & q,
150 float s);
151
152 detail::fquatSIMD operator* (
153 float s,
154 detail::fquatSIMD const & q);
155
156 detail::fquatSIMD operator/ (
157 detail::fquatSIMD const & q,
158 float s);
159
160 }//namespace detail
161
164
165 typedef glm::detail::fquatSIMD simdQuat;
166
169 quat quat_cast(
170 detail::fquatSIMD const & x);
171
174 detail::fquatSIMD quatSIMD_cast(
175 detail::fmat4x4SIMD const & m);
176
179 template <typename T, precision P>
180 detail::fquatSIMD quatSIMD_cast(
181 tmat4x4<T, P> const & m);
182
185 template <typename T, precision P>
186 detail::fquatSIMD quatSIMD_cast(
187 tmat3x3<T, P> const & m);
188
191 detail::fmat4x4SIMD mat4SIMD_cast(
192 detail::fquatSIMD const & q);
193
196 mat4 mat4_cast(
197 detail::fquatSIMD const & q);
198
199
203 float length(
204 detail::fquatSIMD const & x);
205
209 detail::fquatSIMD normalize(
210 detail::fquatSIMD const & x);
211
215 float dot(
216 detail::fquatSIMD const & q1,
217 detail::fquatSIMD const & q2);
218
229 detail::fquatSIMD mix(
230 detail::fquatSIMD const & x,
231 detail::fquatSIMD const & y,
232 float const & a);
233
242 detail::fquatSIMD lerp(
243 detail::fquatSIMD const & x,
244 detail::fquatSIMD const & y,
245 float const & a);
246
255 detail::fquatSIMD slerp(
256 detail::fquatSIMD const & x,
257 detail::fquatSIMD const & y,
258 float const & a);
259
260
271 detail::fquatSIMD fastMix(
272 detail::fquatSIMD const & x,
273 detail::fquatSIMD const & y,
274 float const & a);
275
283 detail::fquatSIMD fastSlerp(
284 detail::fquatSIMD const & x,
285 detail::fquatSIMD const & y,
286 float const & a);
287
288
292 detail::fquatSIMD conjugate(
293 detail::fquatSIMD const & q);
294
298 detail::fquatSIMD inverse(
299 detail::fquatSIMD const & q);
300
307 detail::fquatSIMD angleAxisSIMD(
308 float const & angle,
309 vec3 const & axis);
310
319 detail::fquatSIMD angleAxisSIMD(
320 float const & angle,
321 float const & x,
322 float const & y,
323 float const & z);
324
325 // TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp().
327 __m128 fastSin(__m128 x);
328
330 }//namespace glm
331
332 #include "simd_quat.inl"
333
334
335 #if (GLM_COMPILER & GLM_COMPILER_VC)
336 # pragma warning(pop)
337 #endif
338
339
340 #endif//(GLM_ARCH != GLM_ARCH_PURE)
glm::fastMix
GLM_FUNC_DECL tquat< T, P > fastMix(tquat< T, P > const &x, tquat< T, P > const &y, T const &a)
Quaternion normalized linear interpolation.
glm::length
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::conjugate
GLM_FUNC_DECL tquat< T, P > conjugate(tquat< T, P > const &q)
Returns the q conjugate.
glm::mat4_cast
GLM_FUNC_DECL tmat4x4< T, P > mat4_cast(tquat< T, P > const &x)
Converts a quaternion to a 4 * 4 matrix.
glm::lerp
GLM_FUNC_DECL tquat< T, P > lerp(tquat< T, P > const &x, tquat< T, P > const &y, T a)
Linear interpolation of two quaternions.
glm::normalize
GLM_FUNC_DECL vecType< T, P > normalize(vecType< T, P > const &x)
Returns a vector in the same direction as x but with length of 1.
glm::axis
GLM_FUNC_DECL tvec3< T, P > axis(tquat< T, P > const &x)
Returns the q rotation axis.
glm
Definition: _noise.hpp:40
glm::eulerAngles
GLM_FUNC_DECL tvec3< T, P > eulerAngles(tquat< T, P > const &x)
Returns euler angles, yitch as x, yaw as y, roll as z.
glm::angle
GLM_FUNC_DECL T angle(tquat< T, P > const &x)
Returns the quaternion rotation angle.
glm::vec3
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:395
glm::inverse
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)
Return the inverse of a squared matrix.
glm::fastSin
GLM_FUNC_DECL T fastSin(T angle)
Faster than the common sin function but less accurate.
glm::quat_cast
GLM_FUNC_DECL tquat< T, P > quat_cast(tmat3x3< T, P > const &x)
Converts a 3 * 3 matrix to a quaternion.
glm::slerp
GLM_FUNC_DECL tquat< T, P > slerp(tquat< T, P > const &x, tquat< T, P > const &y, T a)
Spherical linear interpolation of two quaternions.
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::mix
GLM_FUNC_DECL vecType< T, P > mix(vecType< T, P > const &x, vecType< T, P > const &y, vecType< U, P > const &a)
If genTypeU is a floating scalar or vector: Returns x * (1.0 - a) + y * a, i.e., the linear blend of ...
glm::mat4
mat4x4 mat4
4 columns of 4 components matrix of floating-point numbers.
Definition: type_mat.hpp:442