0.9.6
simd_quat.hpp
Go to the documentation of this file.
1 
38 #pragma once
39 
40 // Dependency:
41 #include "../glm.hpp"
42 #include "../gtc/quaternion.hpp"
43 #include "../gtx/fast_trigonometry.hpp"
44 
45 #if(GLM_ARCH != GLM_ARCH_PURE)
46 
47 #if(GLM_ARCH & GLM_ARCH_SSE2)
48 # include "../gtx/simd_mat4.hpp"
49 #else
50 # error "GLM: GLM_GTX_simd_quat requires compiler support of SSE2 through intrinsics"
51 #endif
52 
53 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
54 # pragma message("GLM: GLM_GTX_simd_quat extension included")
55 #endif
56 
57 // Warning silencer for nameless struct/union.
58 #if (GLM_COMPILER & GLM_COMPILER_VC)
59 # pragma warning(push)
60 # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
61 #endif
62 
63 namespace glm{
64 namespace detail
65 {
66  GLM_ALIGNED_STRUCT(16) fquatSIMD
67  {
68  typedef __m128 value_type;
69  typedef std::size_t size_type;
70  static size_type value_size();
71 
72  typedef fquatSIMD type;
73  typedef tquat<bool, defaultp> bool_type;
74 
75 #ifdef GLM_SIMD_ENABLE_XYZW_UNION
76  union
77  {
78  __m128 Data;
79  struct {float x, y, z, w;};
80  };
81 #else
82  __m128 Data;
83 #endif
84 
86  // Implicit basic constructors
87 
88  fquatSIMD();
89  fquatSIMD(__m128 const & Data);
90  fquatSIMD(fquatSIMD const & q);
91 
93  // Explicit basic constructors
94 
95  explicit fquatSIMD(
96  ctor);
97  explicit fquatSIMD(
98  float const & w,
99  float const & x,
100  float const & y,
101  float const & z);
102  explicit fquatSIMD(
103  quat const & v);
104  explicit fquatSIMD(
105  vec3 const & eulerAngles);
106 
107 
109  // Unary arithmetic operators
110 
111  fquatSIMD& operator =(fquatSIMD const & q);
112  fquatSIMD& operator*=(float const & s);
113  fquatSIMD& operator/=(float const & s);
114  };
115 
116 
118  // Arithmetic operators
119 
120  detail::fquatSIMD operator- (
121  detail::fquatSIMD const & q);
122 
123  detail::fquatSIMD operator+ (
124  detail::fquatSIMD const & q,
125  detail::fquatSIMD const & p);
126 
127  detail::fquatSIMD operator* (
128  detail::fquatSIMD const & q,
129  detail::fquatSIMD const & p);
130 
131  detail::fvec4SIMD operator* (
132  detail::fquatSIMD const & q,
133  detail::fvec4SIMD const & v);
134 
135  detail::fvec4SIMD operator* (
136  detail::fvec4SIMD const & v,
137  detail::fquatSIMD const & q);
138 
139  detail::fquatSIMD operator* (
140  detail::fquatSIMD const & q,
141  float s);
142 
143  detail::fquatSIMD operator* (
144  float s,
145  detail::fquatSIMD const & q);
146 
147  detail::fquatSIMD operator/ (
148  detail::fquatSIMD const & q,
149  float s);
150 
151 }//namespace detail
152 
155 
156  typedef glm::detail::fquatSIMD simdQuat;
157 
160  quat quat_cast(
161  detail::fquatSIMD const & x);
162 
165  detail::fquatSIMD quatSIMD_cast(
166  detail::fmat4x4SIMD const & m);
167 
170  template <typename T, precision P>
171  detail::fquatSIMD quatSIMD_cast(
172  tmat4x4<T, P> const & m);
173 
176  template <typename T, precision P>
177  detail::fquatSIMD quatSIMD_cast(
178  tmat3x3<T, P> const & m);
179 
182  detail::fmat4x4SIMD mat4SIMD_cast(
183  detail::fquatSIMD const & q);
184 
187  mat4 mat4_cast(
188  detail::fquatSIMD const & q);
189 
190 
194  float length(
195  detail::fquatSIMD const & x);
196 
200  detail::fquatSIMD normalize(
201  detail::fquatSIMD const & x);
202 
206  float dot(
207  detail::fquatSIMD const & q1,
208  detail::fquatSIMD const & q2);
209 
220  detail::fquatSIMD mix(
221  detail::fquatSIMD const & x,
222  detail::fquatSIMD const & y,
223  float const & a);
224 
233  detail::fquatSIMD lerp(
234  detail::fquatSIMD const & x,
235  detail::fquatSIMD const & y,
236  float const & a);
237 
246  detail::fquatSIMD slerp(
247  detail::fquatSIMD const & x,
248  detail::fquatSIMD const & y,
249  float const & a);
250 
251 
262  detail::fquatSIMD fastMix(
263  detail::fquatSIMD const & x,
264  detail::fquatSIMD const & y,
265  float const & a);
266 
274  detail::fquatSIMD fastSlerp(
275  detail::fquatSIMD const & x,
276  detail::fquatSIMD const & y,
277  float const & a);
278 
279 
283  detail::fquatSIMD conjugate(
284  detail::fquatSIMD const & q);
285 
289  detail::fquatSIMD inverse(
290  detail::fquatSIMD const & q);
291 
298  detail::fquatSIMD angleAxisSIMD(
299  float const & angle,
300  vec3 const & axis);
301 
310  detail::fquatSIMD angleAxisSIMD(
311  float const & angle,
312  float const & x,
313  float const & y,
314  float const & z);
315 
316  // TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp().
318  __m128 fastSin(__m128 x);
319 
321 }//namespace glm
322 
323 #include "simd_quat.inl"
324 
325 
326 #if (GLM_COMPILER & GLM_COMPILER_VC)
327 # pragma warning(pop)
328 #endif
329 
330 
331 #endif//(GLM_ARCH != GLM_ARCH_PURE)
mat4x4 mat4
4 columns of 4 components matrix of floating-point numbers.
Definition: type_mat.hpp:438
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
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_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)
Return the inverse of a squared matrix.
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:393
GLM_FUNC_DECL tquat< T, P > lerp(tquat< T, P > const &x, tquat< T, P > const &y, T const &a)
Linear interpolation of two quaternions.
Definition: _noise.hpp:31
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_FUNC_DECL tvec3< T, P > eulerAngles(tquat< T, P > const &x)
Returns euler angles, yitch as x, yaw as y, roll as z.
GLM_FUNC_DECL tquat< T, P > conjugate(tquat< T, P > const &q)
Returns the q conjugate.
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_FUNC_DECL tquat< T, P > slerp(tquat< T, P > const &x, tquat< T, P > const &y, T const &a)
Spherical linear interpolation of two quaternions.
GLM_FUNC_DECL T fastSin(T angle)
Faster than the common sin function but less accurate.
GLM_FUNC_DECL tmat4x4< T, P > mat4_cast(tquat< T, P > const &x)
Converts a quaternion to a 4 * 4 matrix.
GLM_FUNC_DECL T angle(tquat< T, P > const &x)
Returns the quaternion rotation angle.
GLM_FUNC_DECL tvec3< T, P > axis(tquat< T, P > const &x)
Returns the q rotation axis.
GLM_FUNC_DECL tquat< T, P > quat_cast(tmat3x3< T, P > const &x)
Converts a 3 * 3 matrix to a quaternion.
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.