0.9.8: simd_quat.hpp Source File

| 0.9.8

- Main Page
- Modules
- Files

- File List

simd_quat.hpp
Go to the documentation of this file.
1
13 #pragma once
14
15 // Dependency:
16 #include "../glm.hpp"
17 #include "../gtc/quaternion.hpp"
18 #include "../gtx/fast_trigonometry.hpp"
19
20 #if GLM_ARCH != GLM_ARCH_PURE
21
22 #if GLM_ARCH & GLM_ARCH_SSE2_BIT
23 # include "../gtx/simd_mat4.hpp"
24 #else
25 # error "GLM: GLM_GTX_simd_quat requires compiler support of SSE2 through intrinsics"
26 #endif
27
28 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
29 # pragma message("GLM: GLM_GTX_simd_quat extension included")
30 # pragma message("GLM: GLM_GTX_simd_quat extension is deprecated and will be removed in GLM 0.9.9. Use GLM_GTC_quaternion instead and use compiler SIMD arguments.")
31 #endif
32
33 // Warning silencer for nameless struct/union.
34 #if (GLM_COMPILER & GLM_COMPILER_VC)
35 # pragma warning(push)
36 # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
37 #endif
38
39 namespace glm{
40 namespace detail
41 {
42 GLM_ALIGNED_STRUCT(16) fquatSIMD
43 {
44 typedef float value_type;
45 typedef std::size_t size_type;
46
47 typedef fquatSIMD type;
48 typedef tquat<bool, defaultp> bool_type;
49 typedef tquat<float, defaultp> pure_type;
50
51 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
52 union
53 {
54 __m128 Data;
55 struct {float x, y, z, w;};
56 };
57 #else
58 __m128 Data;
59 #endif
60
62 // Implicit basic constructors
63
64 fquatSIMD() GLM_DEFAULT_CTOR;
65 fquatSIMD(fquatSIMD const & q) GLM_DEFAULT;
66 fquatSIMD(__m128 const & Data);
67
69 // Explicit basic constructors
70
71 explicit fquatSIMD(
72 ctor);
73 explicit fquatSIMD(
74 float const & w,
75 float const & x,
76 float const & y,
77 float const & z);
78 explicit fquatSIMD(
79 quat const & v);
80 explicit fquatSIMD(
81 vec3 const & eulerAngles);
82
83
85 // Unary arithmetic operators
86
87 fquatSIMD& operator= (fquatSIMD const & q) GLM_DEFAULT;
88 fquatSIMD& operator*=(float const & s);
89 fquatSIMD& operator/=(float const & s);
90 };
91
92
94 // Arithmetic operators
95
96 detail::fquatSIMD operator- (
97 detail::fquatSIMD const & q);
98
99 detail::fquatSIMD operator+ (
100 detail::fquatSIMD const & q,
101 detail::fquatSIMD const & p);
102
103 detail::fquatSIMD operator* (
104 detail::fquatSIMD const & q,
105 detail::fquatSIMD const & p);
106
107 detail::fvec4SIMD operator* (
108 detail::fquatSIMD const & q,
109 detail::fvec4SIMD const & v);
110
111 detail::fvec4SIMD operator* (
112 detail::fvec4SIMD const & v,
113 detail::fquatSIMD const & q);
114
115 detail::fquatSIMD operator* (
116 detail::fquatSIMD const & q,
117 float s);
118
119 detail::fquatSIMD operator* (
120 float s,
121 detail::fquatSIMD const & q);
122
123 detail::fquatSIMD operator/ (
124 detail::fquatSIMD const & q,
125 float s);
126
127 }//namespace detail
128
131
132 typedef glm::detail::fquatSIMD simdQuat;
133
136 quat quat_cast(
137 detail::fquatSIMD const & x);
138
141 detail::fquatSIMD quatSIMD_cast(
142 detail::fmat4x4SIMD const & m);
143
146 template <typename T, precision P>
147 detail::fquatSIMD quatSIMD_cast(
148 tmat4x4<T, P> const & m);
149
152 template <typename T, precision P>
153 detail::fquatSIMD quatSIMD_cast(
154 tmat3x3<T, P> const & m);
155
158 detail::fmat4x4SIMD mat4SIMD_cast(
159 detail::fquatSIMD const & q);
160
163 mat4 mat4_cast(
164 detail::fquatSIMD const & q);
165
166
170 float length(
171 detail::fquatSIMD const & x);
172
176 detail::fquatSIMD normalize(
177 detail::fquatSIMD const & x);
178
182 float dot(
183 detail::fquatSIMD const & q1,
184 detail::fquatSIMD const & q2);
185
196 detail::fquatSIMD mix(
197 detail::fquatSIMD const & x,
198 detail::fquatSIMD const & y,
199 float const & a);
200
209 detail::fquatSIMD lerp(
210 detail::fquatSIMD const & x,
211 detail::fquatSIMD const & y,
212 float const & a);
213
222 detail::fquatSIMD slerp(
223 detail::fquatSIMD const & x,
224 detail::fquatSIMD const & y,
225 float const & a);
226
227
238 detail::fquatSIMD fastMix(
239 detail::fquatSIMD const & x,
240 detail::fquatSIMD const & y,
241 float const & a);
242
250 detail::fquatSIMD fastSlerp(
251 detail::fquatSIMD const & x,
252 detail::fquatSIMD const & y,
253 float const & a);
254
255
259 detail::fquatSIMD conjugate(
260 detail::fquatSIMD const & q);
261
265 detail::fquatSIMD inverse(
266 detail::fquatSIMD const & q);
267
274 detail::fquatSIMD angleAxisSIMD(
275 float const & angle,
276 vec3 const & axis);
277
286 detail::fquatSIMD angleAxisSIMD(
287 float const & angle,
288 float const & x,
289 float const & y,
290 float const & z);
291
292 // TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp().
294 __m128 fastSin(__m128 x);
295
297 }//namespace glm
298
299 #include "simd_quat.inl"
300
301
302 #if (GLM_COMPILER & GLM_COMPILER_VC)
303 # pragma warning(pop)
304 #endif
305
306
307 #endif//(GLM_ARCH != GLM_ARCH_PURE)
glm
Definition: _noise.hpp:11
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::inverse
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)
Return the inverse of a squared matrix.
glm::mat4
mat4x4 mat4
4 columns of 4 components matrix of floating-point numbers.
Definition: type_mat.hpp:416
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::conjugate
GLM_FUNC_DECL tquat< T, P > conjugate(tquat< T, P > const &q)
Returns the q conjugate.
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::mat4_cast
GLM_FUNC_DECL tmat4x4< T, P > mat4_cast(tquat< T, P > const &x)
Converts a quaternion to a 4 * 4 matrix.
glm::fastSin
GLM_FUNC_DECL T fastSin(T angle)
Faster than the common sin function but less accurate.
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::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::eulerAngles
GLM_FUNC_DECL tvec3< T, P > eulerAngles(tquat< T, P > const &x)
Returns euler angles, pitch 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::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::length
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::vec3
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:461