0.9.6
dual_quaternion.hpp
Go to the documentation of this file.
1 
41 #pragma once
42 
43 // Dependency:
44 #include "../glm.hpp"
45 #include "../gtc/constants.hpp"
46 #include "../gtc/quaternion.hpp"
47 
48 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
49 # pragma message("GLM: GLM_GTX_dual_quaternion extension included")
50 #endif
51 
52 namespace glm
53 {
56 
57  template <typename T, precision P>
58  struct tdualquat
59  {
60  typedef T value_type;
61  typedef glm::tquat<T, P> part_type;
62 
63  public:
64  glm::tquat<T, P> real, dual;
65 
66 #if GLM_FORCE_SIZE_FUNC
67  GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
69 #else
70  GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
72 #endif//GLM_FORCE_SIZE_FUNC
73 
75  // Implicit basic constructors
76 
77  GLM_FUNC_DECL tdualquat();
78  template <precision Q>
79  GLM_FUNC_DECL tdualquat(tdualquat<T, Q> const & d);
80 
82  // Explicit basic constructors
83 
84  GLM_FUNC_DECL explicit tdualquat(ctor);
85  GLM_FUNC_DECL explicit tdualquat(tquat<T, P> const & real);
86  GLM_FUNC_DECL tdualquat(tquat<T, P> const & orientation, tvec3<T, P> const & translation);
87  GLM_FUNC_DECL tdualquat(tquat<T, P> const & real, tquat<T, P> const & dual);
88 
90  // tdualquat conversions
91 
92 # ifdef GLM_FORCE_EXPLICIT_CTOR
93  template <typename U, precision Q>
94  GLM_FUNC_DECL explicit tdualquat(tdualquat<U, Q> const & q);
95 # else
96  template <typename U, precision Q>
97  GLM_FUNC_DECL tdualquat(tdualquat<U, Q> const & q);
98 # endif
99 
100  GLM_FUNC_DECL explicit tdualquat(tmat2x4<T, P> const & holder_mat);
101  GLM_FUNC_DECL explicit tdualquat(tmat3x4<T, P> const & aug_mat);
102 
103  // Accesses
104  GLM_FUNC_DECL part_type & operator[](int i);
105  GLM_FUNC_DECL part_type const & operator[](int i) const;
106 
107  // Operators
108  GLM_FUNC_DECL tdualquat<T, P> & operator*=(T const & s);
109  GLM_FUNC_DECL tdualquat<T, P> & operator/=(T const & s);
110  };
111 
112  template <typename T, precision P>
113  GLM_FUNC_DECL tquat<T, P> operator- (
114  tquat<T, P> const & q);
115 
116  template <typename T, precision P>
117  GLM_FUNC_DECL tdualquat<T, P> operator+ (
118  tdualquat<T, P> const & q,
119  tdualquat<T, P> const & p);
120 
121  template <typename T, precision P>
122  GLM_FUNC_DECL tdualquat<T, P> operator* (
123  tdualquat<T, P> const & q,
124  tdualquat<T, P> const & p);
125 
126  template <typename T, precision P>
127  GLM_FUNC_DECL tvec3<T, P> operator* (
128  tquat<T, P> const & q,
129  tvec3<T, P> const & v);
130 
131  template <typename T, precision P>
132  GLM_FUNC_DECL tvec3<T, P> operator* (
133  tvec3<T, P> const & v,
134  tquat<T, P> const & q);
135 
136  template <typename T, precision P>
137  GLM_FUNC_DECL tvec4<T, P> operator* (
138  tquat<T, P> const & q,
139  tvec4<T, P> const & v);
140 
141  template <typename T, precision P>
142  GLM_FUNC_DECL tvec4<T, P> operator* (
143  tvec4<T, P> const & v,
144  tquat<T, P> const & q);
145 
146  template <typename T, precision P>
147  GLM_FUNC_DECL tdualquat<T, P> operator* (
148  tdualquat<T, P> const & q,
149  T const & s);
150 
151  template <typename T, precision P>
152  GLM_FUNC_DECL tdualquat<T, P> operator* (
153  T const & s,
154  tdualquat<T, P> const & q);
155 
156  template <typename T, precision P>
157  GLM_FUNC_DECL tdualquat<T, P> operator/ (
158  tdualquat<T, P> const & q,
159  T const & s);
160 
164  template <typename T, precision P>
165  GLM_FUNC_DECL tdualquat<T, P> normalize(
166  tdualquat<T, P> const & q);
167 
171  template <typename T, precision P>
172  GLM_FUNC_DECL tdualquat<T, P> lerp(
173  tdualquat<T, P> const & x,
174  tdualquat<T, P> const & y,
175  T const & a);
176 
180  template <typename T, precision P>
181  GLM_FUNC_DECL tdualquat<T, P> inverse(
182  tdualquat<T, P> const & q);
183 
187  template <typename T, precision P>
188  GLM_FUNC_DECL tmat2x4<T, P> mat2x4_cast(
189  tdualquat<T, P> const & x);
190 
194  template <typename T, precision P>
195  GLM_FUNC_DECL tmat3x4<T, P> mat3x4_cast(
196  tdualquat<T, P> const & x);
197 
201  template <typename T, precision P>
202  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(
203  tmat2x4<T, P> const & x);
204 
208  template <typename T, precision P>
209  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(
210  tmat3x4<T, P> const & x);
211 
212 
216  typedef tdualquat<float, lowp> lowp_dualquat;
217 
221  typedef tdualquat<float, mediump> mediump_dualquat;
222 
226  typedef tdualquat<float, highp> highp_dualquat;
227 
228 
232  typedef tdualquat<float, lowp> lowp_fdualquat;
233 
237  typedef tdualquat<float, mediump> mediump_fdualquat;
238 
242  typedef tdualquat<float, highp> highp_fdualquat;
243 
244 
248  typedef tdualquat<double, lowp> lowp_ddualquat;
249 
253  typedef tdualquat<double, mediump> mediump_ddualquat;
254 
258  typedef tdualquat<double, highp> highp_ddualquat;
259 
260 
261 #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
262  typedef highp_fdualquat dualquat;
266 
270  typedef highp_fdualquat fdualquat;
271 #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
272  typedef highp_fdualquat dualquat;
273  typedef highp_fdualquat fdualquat;
274 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
275  typedef mediump_fdualquat dualquat;
276  typedef mediump_fdualquat fdualquat;
277 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
278  typedef lowp_fdualquat dualquat;
279  typedef lowp_fdualquat fdualquat;
280 #else
281 # error "GLM error: multiple default precision requested for single-precision floating-point types"
282 #endif
283 
284 
285 #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
286  typedef highp_ddualquat ddualquat;
290 #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
291  typedef highp_ddualquat ddualquat;
292 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
293  typedef mediump_ddualquat ddualquat;
294 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
295  typedef lowp_ddualquat ddualquat;
296 #else
297 # error "GLM error: Multiple default precision requested for double-precision floating-point types"
298 #endif
299 
301 } //namespace glm
302 
303 #include "dual_quaternion.inl"
GLM_FUNC_DECL tdualquat< T, P > lerp(tdualquat< T, P > const &x, tdualquat< T, P > const &y, T const &a)
Returns the linear interpolation of two dual quaternion.
tdualquat< double, lowp > lowp_ddualquat
Dual-quaternion of low double-precision floating-point numbers.
highp_ddualquat ddualquat
Dual-quaternion of default double-precision floating-point numbers.
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
tdualquat< double, highp > highp_ddualquat
Dual-quaternion of high double-precision floating-point numbers.
GLM_FUNC_DECL tdualquat< T, P > normalize(tdualquat< T, P > const &q)
Returns the normalized quaternion.
GLM_FUNC_DECL tmat2x4< T, P > mat2x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 2 * 4 matrix.
tdualquat< float, lowp > lowp_fdualquat
Dual-quaternion of low single-precision floating-point numbers.
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
GLM_FUNC_DECL tmat3x4< T, P > mat3x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 3 * 4 matrix.
tdualquat< float, highp > highp_fdualquat
Dual-quaternion of high single-precision floating-point numbers.
Definition: _noise.hpp:31
GLM_FUNC_DECL tdualquat< T, P > dualquat_cast(tmat3x4< T, P > const &x)
Converts a 3 * 4 matrix (augmented matrix rotation + translation) to a quaternion.
tdualquat< float, highp > highp_dualquat
Dual-quaternion of high single-precision floating-point numbers.
tdualquat< float, mediump > mediump_fdualquat
Dual-quaternion of medium single-precision floating-point numbers.
tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-precision floating-point numbers.
highp_fdualquat fdualquat
Dual-quaternion of single-precision floating-point numbers.
tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-precision floating-point numbers.
GLM_FUNC_DECL tmat4x4< T, P > orientation(tvec3< T, P > const &Normal, tvec3< T, P > const &Up)
Build a rotation matrix from a normal and a up vector.
GLM_FUNC_DECL tdualquat< T, P > inverse(tdualquat< T, P > const &q)
Returns the q inverse.
tdualquat< double, mediump > mediump_ddualquat
Dual-quaternion of medium double-precision floating-point numbers.