0.9.9 API documenation
dual_quaternion.hpp
Go to the documentation of this file.
1 
16 #pragma once
17 
18 // Dependency:
19 #include "../glm.hpp"
20 #include "../gtc/constants.hpp"
21 #include "../gtc/quaternion.hpp"
22 
23 #ifndef GLM_ENABLE_EXPERIMENTAL
24 # error "GLM: GLM_GTX_dual_quaternion is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
25 #endif
26 
27 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
28 # pragma message("GLM: GLM_GTX_dual_quaternion extension included")
29 #endif
30 
31 namespace glm
32 {
35 
36  template<typename T, qualifier P = defaultp>
37  struct tdualquat
38  {
39  // -- Implementation detail --
40 
41  typedef T value_type;
42  typedef glm::tquat<T, P> part_type;
43 
44  // -- Data --
45 
46  glm::tquat<T, P> real, dual;
47 
48  // -- Component accesses --
49 
50  typedef length_t length_type;
52  GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 2;}
53 
54  GLM_FUNC_DECL part_type & operator[](length_type i);
55  GLM_FUNC_DECL part_type const & operator[](length_type i) const;
56 
57  // -- Implicit basic constructors --
58 
59  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat() GLM_DEFAULT;
60  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, P> const & d) GLM_DEFAULT;
61  template<qualifier Q>
62  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, Q> const & d);
63 
64  // -- Explicit basic constructors --
65 
66  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tquat<T, P> const & real);
67  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tquat<T, P> const & orientation, vec<3, T, P> const & translation);
68  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tquat<T, P> const & real, tquat<T, P> const & dual);
69 
70  // -- Conversion constructors --
71 
72  template<typename U, qualifier Q>
73  GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tdualquat(tdualquat<U, Q> const & q);
74 
75  GLM_FUNC_DECL GLM_EXPLICIT tdualquat(mat<2, 4, T, P> const & holder_mat);
76  GLM_FUNC_DECL GLM_EXPLICIT tdualquat(mat<3, 4, T, P> const & aug_mat);
77 
78  // -- Unary arithmetic operators --
79 
80  GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<T, P> const & m) GLM_DEFAULT;
81 
82  template<typename U>
83  GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<U, P> const & m);
84  template<typename U>
85  GLM_FUNC_DECL tdualquat<T, P> & operator*=(U s);
86  template<typename U>
87  GLM_FUNC_DECL tdualquat<T, P> & operator/=(U s);
88  };
89 
90  // -- Unary bit operators --
91 
92  template<typename T, qualifier P>
93  GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q);
94 
95  template<typename T, qualifier P>
96  GLM_FUNC_DECL tdualquat<T, P> operator-(tdualquat<T, P> const & q);
97 
98  // -- Binary operators --
99 
100  template<typename T, qualifier P>
101  GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
102 
103  template<typename T, qualifier P>
104  GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
105 
106  template<typename T, qualifier P>
107  GLM_FUNC_DECL vec<3, T, P> operator*(tdualquat<T, P> const & q, vec<3, T, P> const & v);
108 
109  template<typename T, qualifier P>
110  GLM_FUNC_DECL vec<3, T, P> operator*(vec<3, T, P> const & v, tdualquat<T, P> const & q);
111 
112  template<typename T, qualifier P>
113  GLM_FUNC_DECL vec<4, T, P> operator*(tdualquat<T, P> const & q, vec<4, T, P> const & v);
114 
115  template<typename T, qualifier P>
116  GLM_FUNC_DECL vec<4, T, P> operator*(vec<4, T, P> const & v, tdualquat<T, P> const & q);
117 
118  template<typename T, qualifier P>
119  GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, T const & s);
120 
121  template<typename T, qualifier P>
122  GLM_FUNC_DECL tdualquat<T, P> operator*(T const & s, tdualquat<T, P> const & q);
123 
124  template<typename T, qualifier P>
125  GLM_FUNC_DECL tdualquat<T, P> operator/(tdualquat<T, P> const & q, T const & s);
126 
127  // -- Boolean operators --
128 
129  template<typename T, qualifier P>
130  GLM_FUNC_DECL bool operator==(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2);
131 
132  template<typename T, qualifier P>
133  GLM_FUNC_DECL bool operator!=(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2);
134 
138  template <typename T, qualifier P>
139  GLM_FUNC_DECL tdualquat<T, P> dual_quat_identity();
140 
144  template<typename T, qualifier P>
145  GLM_FUNC_DECL tdualquat<T, P> normalize(tdualquat<T, P> const & q);
146 
150  template<typename T, qualifier P>
151  GLM_FUNC_DECL tdualquat<T, P> lerp(tdualquat<T, P> const & x, tdualquat<T, P> const & y, T const & a);
152 
156  template<typename T, qualifier P>
157  GLM_FUNC_DECL tdualquat<T, P> inverse(tdualquat<T, P> const & q);
158 
162  template<typename T, qualifier P>
163  GLM_FUNC_DECL mat<2, 4, T, P> mat2x4_cast(tdualquat<T, P> const & x);
164 
168  template<typename T, qualifier P>
169  GLM_FUNC_DECL mat<3, 4, T, P> mat3x4_cast(tdualquat<T, P> const & x);
170 
174  template<typename T, qualifier P>
175  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(mat<2, 4, T, P> const & x);
176 
180  template<typename T, qualifier P>
181  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(mat<3, 4, T, P> const & x);
182 
183 
187  typedef tdualquat<float, lowp> lowp_dualquat;
188 
192  typedef tdualquat<float, mediump> mediump_dualquat;
193 
197  typedef tdualquat<float, highp> highp_dualquat;
198 
199 
203  typedef tdualquat<float, lowp> lowp_fdualquat;
204 
208  typedef tdualquat<float, mediump> mediump_fdualquat;
209 
213  typedef tdualquat<float, highp> highp_fdualquat;
214 
215 
219  typedef tdualquat<double, lowp> lowp_ddualquat;
220 
224  typedef tdualquat<double, mediump> mediump_ddualquat;
225 
229  typedef tdualquat<double, highp> highp_ddualquat;
230 
231 
232 #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
233  typedef highp_fdualquat dualquat;
237 
241  typedef highp_fdualquat fdualquat;
242 #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
243  typedef highp_fdualquat dualquat;
244  typedef highp_fdualquat fdualquat;
245 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
246  typedef mediump_fdualquat dualquat;
247  typedef mediump_fdualquat fdualquat;
248 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
249  typedef lowp_fdualquat dualquat;
250  typedef lowp_fdualquat fdualquat;
251 #else
252 # error "GLM error: multiple default precision requested for single-precision floating-point types"
253 #endif
254 
255 
256 #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
257  typedef highp_ddualquat ddualquat;
261 #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
262  typedef highp_ddualquat ddualquat;
263 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
264  typedef mediump_ddualquat ddualquat;
265 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
266  typedef lowp_ddualquat ddualquat;
267 #else
268 # error "GLM error: Multiple default precision requested for double-precision floating-point types"
269 #endif
270 
272 } //namespace glm
273 
274 #include "dual_quaternion.inl"
tdualquat< float, highp > highp_dualquat
Dual-quaternion of high single-qualifier floating-point numbers.
GLM_FUNC_DECL tdualquat< T, P > dualquat_cast(mat< 3, 4, T, P > const &x)
Converts a 3 * 4 matrix (augmented matrix rotation + translation) to a quaternion.
GLM_FUNC_DECL mat< 4, 4, T, P > orientation(vec< 3, T, P > const &Normal, vec< 3, T, P > const &Up)
Build a rotation matrix from a normal and a up vector.
highp_fdualquat fdualquat
Dual-quaternion of single-qualifier floating-point numbers.
tdualquat< float, mediump > mediump_fdualquat
Dual-quaternion of medium single-qualifier floating-point numbers.
tdualquat< double, mediump > mediump_ddualquat
Dual-quaternion of medium double-qualifier floating-point numbers.
Definition: _noise.hpp:11
GLM_FUNC_DECL tdualquat< T, P > inverse(tdualquat< T, P > const &q)
Returns the q inverse.
tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-qualifier floating-point numbers.
GLM_FUNC_DECL mat< 2, 4, T, P > mat2x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 2 * 4 matrix.
tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-qualifier floating-point numbers.
tdualquat< double, lowp > lowp_ddualquat
Dual-quaternion of low double-qualifier floating-point numbers.
GLM_FUNC_DECL tdualquat< T, P > dual_quat_identity()
Creates an identity dual 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.
highp_ddualquat ddualquat
Dual-quaternion of default double-qualifier floating-point numbers.
GLM_FUNC_DECL mat< 3, 4, T, P > mat3x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 3 * 4 matrix.
tdualquat< double, highp > highp_ddualquat
Dual-quaternion of high double-qualifier floating-point numbers.
tdualquat< float, lowp > lowp_fdualquat
Dual-quaternion of low single-qualifier floating-point numbers.
GLM_FUNC_DECL T length(vec< L, T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
tdualquat< float, highp > highp_fdualquat
Dual-quaternion of high single-qualifier floating-point numbers.
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
GLM_FUNC_DECL tdualquat< T, P > normalize(tdualquat< T, P > const &q)
Returns the normalized quaternion.