0.9.6
dual_quaternion.hpp
Go to the documentation of this file.
1 
45 #pragma once
46 
47 // Dependency:
48 #include "../glm.hpp"
49 #include "../gtc/constants.hpp"
50 #include "../gtc/quaternion.hpp"
51 
52 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
53 # pragma message("GLM: GLM_GTX_dual_quaternion extension included")
54 #endif
55 
56 namespace glm
57 {
60 
61  template <typename T, precision P>
62  struct tdualquat
63  {
64  typedef T value_type;
65  typedef glm::tquat<T, P> part_type;
66 
67  public:
68  glm::tquat<T, P> real, dual;
69 
71  // Component accesses
72 
73 # ifdef GLM_FORCE_SIZE_FUNC
74  typedef size_t size_type;
76  GLM_FUNC_DECL GLM_CONSTEXPR size_type size() const;
77 
78  GLM_FUNC_DECL part_type & operator[](size_type i);
79  GLM_FUNC_DECL part_type const & operator[](size_type i) const;
80 # else
81  typedef length_t length_type;
83  GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
84 
85  GLM_FUNC_DECL part_type & operator[](length_type i);
86  GLM_FUNC_DECL part_type const & operator[](length_type i) const;
87 # endif//GLM_FORCE_SIZE_FUNC
88 
90  // Implicit basic constructors
91 
92  GLM_FUNC_DECL tdualquat();
93  template <precision Q>
94  GLM_FUNC_DECL tdualquat(tdualquat<T, Q> const & d);
95 
97  // Explicit basic constructors
98 
99  GLM_FUNC_DECL explicit tdualquat(ctor);
100  GLM_FUNC_DECL explicit tdualquat(tquat<T, P> const & real);
101  GLM_FUNC_DECL tdualquat(tquat<T, P> const & orientation, tvec3<T, P> const & translation);
102  GLM_FUNC_DECL tdualquat(tquat<T, P> const & real, tquat<T, P> const & dual);
103 
105  // tdualquat conversions
106 
107 # ifdef GLM_FORCE_EXPLICIT_CTOR
108  template <typename U, precision Q>
109  GLM_FUNC_DECL explicit tdualquat(tdualquat<U, Q> const & q);
110 # else
111  template <typename U, precision Q>
112  GLM_FUNC_DECL tdualquat(tdualquat<U, Q> const & q);
113 # endif
114 
115  GLM_FUNC_DECL explicit tdualquat(tmat2x4<T, P> const & holder_mat);
116  GLM_FUNC_DECL explicit tdualquat(tmat3x4<T, P> const & aug_mat);
117 
118  // Operators
119  GLM_FUNC_DECL tdualquat<T, P> & operator*=(T const & s);
120  GLM_FUNC_DECL tdualquat<T, P> & operator/=(T const & s);
121  };
122 
123  template <typename T, precision P>
124  GLM_FUNC_DECL tquat<T, P> operator- (
125  tquat<T, P> const & q);
126 
127  template <typename T, precision P>
128  GLM_FUNC_DECL tdualquat<T, P> operator+ (
129  tdualquat<T, P> const & q,
130  tdualquat<T, P> const & p);
131 
132  template <typename T, precision P>
133  GLM_FUNC_DECL tdualquat<T, P> operator* (
134  tdualquat<T, P> const & q,
135  tdualquat<T, P> const & p);
136 
137  template <typename T, precision P>
138  GLM_FUNC_DECL tvec3<T, P> operator* (
139  tquat<T, P> const & q,
140  tvec3<T, P> const & v);
141 
142  template <typename T, precision P>
143  GLM_FUNC_DECL tvec3<T, P> operator* (
144  tvec3<T, P> const & v,
145  tquat<T, P> const & q);
146 
147  template <typename T, precision P>
148  GLM_FUNC_DECL tvec4<T, P> operator* (
149  tquat<T, P> const & q,
150  tvec4<T, P> const & v);
151 
152  template <typename T, precision P>
153  GLM_FUNC_DECL tvec4<T, P> operator* (
154  tvec4<T, P> const & v,
155  tquat<T, P> const & q);
156 
157  template <typename T, precision P>
158  GLM_FUNC_DECL tdualquat<T, P> operator* (
159  tdualquat<T, P> const & q,
160  T const & s);
161 
162  template <typename T, precision P>
163  GLM_FUNC_DECL tdualquat<T, P> operator* (
164  T const & s,
165  tdualquat<T, P> const & q);
166 
167  template <typename T, precision P>
168  GLM_FUNC_DECL tdualquat<T, P> operator/ (
169  tdualquat<T, P> const & q,
170  T const & s);
171 
175  template <typename T, precision P>
176  GLM_FUNC_DECL tdualquat<T, P> normalize(
177  tdualquat<T, P> const & q);
178 
182  template <typename T, precision P>
183  GLM_FUNC_DECL tdualquat<T, P> lerp(
184  tdualquat<T, P> const & x,
185  tdualquat<T, P> const & y,
186  T const & a);
187 
191  template <typename T, precision P>
192  GLM_FUNC_DECL tdualquat<T, P> inverse(
193  tdualquat<T, P> const & q);
194 
198  template <typename T, precision P>
199  GLM_FUNC_DECL tmat2x4<T, P> mat2x4_cast(
200  tdualquat<T, P> const & x);
201 
205  template <typename T, precision P>
206  GLM_FUNC_DECL tmat3x4<T, P> mat3x4_cast(
207  tdualquat<T, P> const & x);
208 
212  template <typename T, precision P>
213  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(
214  tmat2x4<T, P> const & x);
215 
219  template <typename T, precision P>
220  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(
221  tmat3x4<T, P> const & x);
222 
223 
227  typedef tdualquat<float, lowp> lowp_dualquat;
228 
232  typedef tdualquat<float, mediump> mediump_dualquat;
233 
237  typedef tdualquat<float, highp> highp_dualquat;
238 
239 
243  typedef tdualquat<float, lowp> lowp_fdualquat;
244 
248  typedef tdualquat<float, mediump> mediump_fdualquat;
249 
253  typedef tdualquat<float, highp> highp_fdualquat;
254 
255 
259  typedef tdualquat<double, lowp> lowp_ddualquat;
260 
264  typedef tdualquat<double, mediump> mediump_ddualquat;
265 
269  typedef tdualquat<double, highp> highp_ddualquat;
270 
271 
272 #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
273  typedef highp_fdualquat dualquat;
277 
281  typedef highp_fdualquat fdualquat;
282 #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
283  typedef highp_fdualquat dualquat;
284  typedef highp_fdualquat fdualquat;
285 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
286  typedef mediump_fdualquat dualquat;
287  typedef mediump_fdualquat fdualquat;
288 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
289  typedef lowp_fdualquat dualquat;
290  typedef lowp_fdualquat fdualquat;
291 #else
292 # error "GLM error: multiple default precision requested for single-precision floating-point types"
293 #endif
294 
295 
296 #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
297  typedef highp_ddualquat ddualquat;
301 #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
302  typedef highp_ddualquat ddualquat;
303 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
304  typedef mediump_ddualquat ddualquat;
305 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
306  typedef lowp_ddualquat ddualquat;
307 #else
308 # error "GLM error: Multiple default precision requested for double-precision floating-point types"
309 #endif
310 
312 } //namespace glm
313 
314 #include "dual_quaternion.inl"
tdualquat< float, lowp > lowp_fdualquat
Dual-quaternion of low single-precision floating-point numbers.
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-precision floating-point numbers.
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.
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< float, highp > highp_dualquat
Dual-quaternion of high single-precision floating-point numbers.
tdualquat< double, lowp > lowp_ddualquat
Dual-quaternion of low double-precision floating-point numbers.
tdualquat< double, highp > highp_ddualquat
Dual-quaternion of high double-precision floating-point numbers.
highp_ddualquat ddualquat
Dual-quaternion of default double-precision floating-point numbers.
tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-precision floating-point numbers.
GLM_FUNC_DECL tmat2x4< T, P > mat2x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 2 * 4 matrix.
highp_fdualquat fdualquat
Dual-quaternion of single-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, mediump > mediump_ddualquat
Dual-quaternion of medium double-precision 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.
GLM_FUNC_DECL tdualquat< T, P > inverse(tdualquat< T, P > const &q)
Returns the q inverse.
Definition: _noise.hpp:39
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 > normalize(tdualquat< T, P > const &q)
Returns the normalized quaternion.
tdualquat< float, mediump > mediump_fdualquat
Dual-quaternion of medium single-precision floating-point numbers.