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 experimetal 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, precision 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 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_CTOR;
60  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, P> const & d) GLM_DEFAULT;
61  template <precision 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_CTOR explicit tdualquat(ctor);
67  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tquat<T, P> const & real);
68  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tquat<T, P> const & orientation, tvec3<T, P> const & translation);
69  GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tquat<T, P> const & real, tquat<T, P> const & dual);
70 
71  // -- Conversion constructors --
72 
73  template <typename U, precision Q>
74  GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tdualquat(tdualquat<U, Q> const & q);
75 
76  GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tmat2x4<T, P> const & holder_mat);
77  GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tmat3x4<T, P> const & aug_mat);
78 
79  // -- Unary arithmetic operators --
80 
81  GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<T, P> const & m) GLM_DEFAULT;
82 
83  template <typename U>
84  GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<U, P> const & m);
85  template <typename U>
86  GLM_FUNC_DECL tdualquat<T, P> & operator*=(U s);
87  template <typename U>
88  GLM_FUNC_DECL tdualquat<T, P> & operator/=(U s);
89  };
90 
91  // -- Unary bit operators --
92 
93  template <typename T, precision P>
94  GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q);
95 
96  template <typename T, precision P>
97  GLM_FUNC_DECL tdualquat<T, P> operator-(tdualquat<T, P> const & q);
98 
99  // -- Binary operators --
100 
101  template <typename T, precision P>
102  GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
103 
104  template <typename T, precision P>
105  GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
106 
107  template <typename T, precision P>
108  GLM_FUNC_DECL tvec3<T, P> operator*(tdualquat<T, P> const & q, tvec3<T, P> const & v);
109 
110  template <typename T, precision P>
111  GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tdualquat<T, P> const & q);
112 
113  template <typename T, precision P>
114  GLM_FUNC_DECL tvec4<T, P> operator*(tdualquat<T, P> const & q, tvec4<T, P> const & v);
115 
116  template <typename T, precision P>
117  GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tdualquat<T, P> const & q);
118 
119  template <typename T, precision P>
120  GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, T const & s);
121 
122  template <typename T, precision P>
123  GLM_FUNC_DECL tdualquat<T, P> operator*(T const & s, tdualquat<T, P> const & q);
124 
125  template <typename T, precision P>
126  GLM_FUNC_DECL tdualquat<T, P> operator/(tdualquat<T, P> const & q, T const & s);
127 
128  // -- Boolean operators --
129 
130  template <typename T, precision P>
131  GLM_FUNC_DECL bool operator==(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2);
132 
133  template <typename T, precision P>
134  GLM_FUNC_DECL bool operator!=(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2);
135 
139  template <typename T, precision P>
140  GLM_FUNC_DECL tdualquat<T, P> normalize(tdualquat<T, P> const & q);
141 
145  template <typename T, precision P>
146  GLM_FUNC_DECL tdualquat<T, P> lerp(tdualquat<T, P> const & x, tdualquat<T, P> const & y, T const & a);
147 
151  template <typename T, precision P>
152  GLM_FUNC_DECL tdualquat<T, P> inverse(tdualquat<T, P> const & q);
153 
157  template <typename T, precision P>
158  GLM_FUNC_DECL tmat2x4<T, P> mat2x4_cast(tdualquat<T, P> const & x);
159 
163  template <typename T, precision P>
164  GLM_FUNC_DECL tmat3x4<T, P> mat3x4_cast(tdualquat<T, P> const & x);
165 
169  template <typename T, precision P>
170  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat2x4<T, P> const & x);
171 
175  template <typename T, precision P>
176  GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat3x4<T, P> const & x);
177 
178 
182  typedef tdualquat<float, lowp> lowp_dualquat;
183 
187  typedef tdualquat<float, mediump> mediump_dualquat;
188 
192  typedef tdualquat<float, highp> highp_dualquat;
193 
194 
198  typedef tdualquat<float, lowp> lowp_fdualquat;
199 
203  typedef tdualquat<float, mediump> mediump_fdualquat;
204 
208  typedef tdualquat<float, highp> highp_fdualquat;
209 
210 
214  typedef tdualquat<double, lowp> lowp_ddualquat;
215 
219  typedef tdualquat<double, mediump> mediump_ddualquat;
220 
224  typedef tdualquat<double, highp> highp_ddualquat;
225 
226 
227 #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
228  typedef highp_fdualquat dualquat;
232 
236  typedef highp_fdualquat fdualquat;
237 #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
238  typedef highp_fdualquat dualquat;
239  typedef highp_fdualquat fdualquat;
240 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
241  typedef mediump_fdualquat dualquat;
242  typedef mediump_fdualquat fdualquat;
243 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
244  typedef lowp_fdualquat dualquat;
245  typedef lowp_fdualquat fdualquat;
246 #else
247 # error "GLM error: multiple default precision requested for single-precision floating-point types"
248 #endif
249 
250 
251 #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
252  typedef highp_ddualquat ddualquat;
256 #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
257  typedef highp_ddualquat ddualquat;
258 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
259  typedef mediump_ddualquat ddualquat;
260 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
261  typedef lowp_ddualquat ddualquat;
262 #else
263 # error "GLM error: Multiple default precision requested for double-precision floating-point types"
264 #endif
265 
267 } //namespace glm
268 
269 #include "dual_quaternion.inl"
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.
tdualquat< float, lowp > lowp_fdualquat
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.
highp_fdualquat fdualquat
Dual-quaternion of single-precision floating-point numbers.
tdualquat< double, mediump > mediump_ddualquat
Dual-quaternion of medium double-precision floating-point numbers.
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.
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
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.
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
tdualquat< float, highp > highp_fdualquat
Dual-quaternion of high single-precision floating-point numbers.
tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-precision floating-point numbers.
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.
GLM_FUNC_DECL tmat3x4< T, P > mat3x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 3 * 4 matrix.
Definition: _noise.hpp:11
tdualquat< float, highp > highp_dualquat
Dual-quaternion of high 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.
tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-precision floating-point numbers.
GLM_FUNC_DECL tdualquat< T, P > inverse(tdualquat< T, P > const &q)
Returns the q inverse.
tdualquat< double, highp > highp_ddualquat
Dual-quaternion of high double-precision floating-point numbers.