0.9.7: dual_quaternion.hpp Source File

| 0.9.7

- Main Page
- Modules
- Files

- File List

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 = defaultp>
62 struct tdualquat
63 {
64 // -- Implementation detail --
65
66 typedef T value_type;
67 typedef glm::tquat<T, P> part_type;
68
69 # ifdef GLM_META_PROG_HELPERS
70 static GLM_RELAXED_CONSTEXPR length_t components = 2;
71 static GLM_RELAXED_CONSTEXPR precision prec = P;
72 # endif//GLM_META_PROG_HELPERS
73
74 // -- Data --
75
76 glm::tquat<T, P> real, dual;
77
78 // -- Component accesses --
79
80 # ifdef GLM_FORCE_SIZE_FUNC
81 typedef size_t size_type;
83 GLM_FUNC_DECL GLM_CONSTEXPR size_type size() const;
84
85 GLM_FUNC_DECL part_type & operator[](size_type i);
86 GLM_FUNC_DECL part_type const & operator[](size_type i) const;
87 # else
88 typedef length_t length_type;
90 GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
91
92 GLM_FUNC_DECL part_type & operator[](length_type i);
93 GLM_FUNC_DECL part_type const & operator[](length_type i) const;
94 # endif//GLM_FORCE_SIZE_FUNC
95
96 // -- Implicit basic constructors --
97
98 GLM_FUNC_DECL tdualquat() GLM_DEFAULT_CTOR;
99 GLM_FUNC_DECL tdualquat(tdualquat<T, P> const & d) GLM_DEFAULT;
100 template <precision Q>
101 GLM_FUNC_DECL tdualquat(tdualquat<T, Q> const & d);
102
103 // -- Explicit basic constructors --
104
105 GLM_FUNC_DECL explicit tdualquat(ctor);
106 GLM_FUNC_DECL explicit tdualquat(tquat<T, P> const & real);
107 GLM_FUNC_DECL tdualquat(tquat<T, P> const & orientation, tvec3<T, P> const & translation);
108 GLM_FUNC_DECL tdualquat(tquat<T, P> const & real, tquat<T, P> const & dual);
109
110 // -- Conversion constructors --
111
112 template <typename U, precision Q>
113 GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tdualquat<U, Q> const & q);
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 // -- Unary arithmetic operators --
119
120 GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<T, P> const & m) GLM_DEFAULT;
121
122 template <typename U>
123 GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<U, P> const & m);
124 template <typename U>
125 GLM_FUNC_DECL tdualquat<T, P> & operator*=(U s);
126 template <typename U>
127 GLM_FUNC_DECL tdualquat<T, P> & operator/=(U s);
128 };
129
130 // -- Unary bit operators --
131
132 template <typename T, precision P>
133 GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
134
135 // -- Binary operators --
136
137 template <typename T, precision P>
138 GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
139
140 template <typename T, precision P>
141 GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
142
143 template <typename T, precision P>
144 GLM_FUNC_DECL tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v);
145
146 template <typename T, precision P>
147 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q);
148
149 template <typename T, precision P>
150 GLM_FUNC_DECL tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v);
151
152 template <typename T, precision P>
153 GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q);
154
155 template <typename T, precision P>
156 GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, T const & s);
157
158 template <typename T, precision P>
159 GLM_FUNC_DECL tdualquat<T, P> operator*(T const & s, tdualquat<T, P> const & q);
160
161 template <typename T, precision P>
162 GLM_FUNC_DECL tdualquat<T, P> operator/(tdualquat<T, P> const & q, T const & s);
163
167 template <typename T, precision P>
168 GLM_FUNC_DECL tdualquat<T, P> normalize(tdualquat<T, P> const & q);
169
173 template <typename T, precision P>
174 GLM_FUNC_DECL tdualquat<T, P> lerp(tdualquat<T, P> const & x, tdualquat<T, P> const & y, T const & a);
175
179 template <typename T, precision P>
180 GLM_FUNC_DECL tdualquat<T, P> inverse(tdualquat<T, P> const & q);
181
185 template <typename T, precision P>
186 GLM_FUNC_DECL tmat2x4<T, P> mat2x4_cast(tdualquat<T, P> const & x);
187
191 template <typename T, precision P>
192 GLM_FUNC_DECL tmat3x4<T, P> mat3x4_cast(tdualquat<T, P> const & x);
193
197 template <typename T, precision P>
198 GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat2x4<T, P> const & x);
199
203 template <typename T, precision P>
204 GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat3x4<T, P> const & x);
205
206
210 typedef tdualquat<float, lowp> lowp_dualquat;
211
215 typedef tdualquat<float, mediump> mediump_dualquat;
216
220 typedef tdualquat<float, highp> highp_dualquat;
221
222
226 typedef tdualquat<float, lowp> lowp_fdualquat;
227
231 typedef tdualquat<float, mediump> mediump_fdualquat;
232
236 typedef tdualquat<float, highp> highp_fdualquat;
237
238
242 typedef tdualquat<double, lowp> lowp_ddualquat;
243
247 typedef tdualquat<double, mediump> mediump_ddualquat;
248
252 typedef tdualquat<double, highp> highp_ddualquat;
253
254
255 #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
256 typedef highp_fdualquat dualquat;
260
264 typedef highp_fdualquat fdualquat;
265 #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
266 typedef highp_fdualquat dualquat;
267 typedef highp_fdualquat fdualquat;
268 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
269 typedef mediump_fdualquat dualquat;
270 typedef mediump_fdualquat fdualquat;
271 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
272 typedef lowp_fdualquat dualquat;
273 typedef lowp_fdualquat fdualquat;
274 #else
275 # error "GLM error: multiple default precision requested for single-precision floating-point types"
276 #endif
277
278
279 #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
280 typedef highp_ddualquat ddualquat;
284 #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
285 typedef highp_ddualquat ddualquat;
286 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
287 typedef mediump_ddualquat ddualquat;
288 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
289 typedef lowp_ddualquat ddualquat;
290 #else
291 # error "GLM error: Multiple default precision requested for double-precision floating-point types"
292 #endif
293
295 } //namespace glm
296
297 #include "dual_quaternion.inl"
glm::dualquat_cast
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::lowp_ddualquat
tdualquat< double, lowp > lowp_ddualquat
Dual-quaternion of low double-precision floating-point numbers.
Definition: dual_quaternion.hpp:242
glm::normalize
GLM_FUNC_DECL tdualquat< T, P > normalize(tdualquat< T, P > const &q)
Returns the normalized quaternion.
glm::highp_dualquat
tdualquat< float, highp > highp_dualquat
Dual-quaternion of high single-precision floating-point numbers.
Definition: dual_quaternion.hpp:220
glm::orientation
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::mediump_fdualquat
tdualquat< float, mediump > mediump_fdualquat
Dual-quaternion of medium single-precision floating-point numbers.
Definition: dual_quaternion.hpp:231
glm::fdualquat
highp_fdualquat fdualquat
Dual-quaternion of single-precision floating-point numbers.
Definition: dual_quaternion.hpp:264
glm::length
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::lowp_dualquat
tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-precision floating-point numbers.
Definition: dual_quaternion.hpp:210
glm::lerp
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::mat2x4_cast
GLM_FUNC_DECL tmat2x4< T, P > mat2x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 2 * 4 matrix.
glm::ddualquat
highp_ddualquat ddualquat
Dual-quaternion of default double-precision floating-point numbers.
Definition: dual_quaternion.hpp:283
glm::highp_ddualquat
tdualquat< double, highp > highp_ddualquat
Dual-quaternion of high double-precision floating-point numbers.
Definition: dual_quaternion.hpp:252
glm::highp_fdualquat
tdualquat< float, highp > highp_fdualquat
Dual-quaternion of high single-precision floating-point numbers.
Definition: dual_quaternion.hpp:236
glm
Definition: _noise.hpp:40
glm::inverse
GLM_FUNC_DECL tdualquat< T, P > inverse(tdualquat< T, P > const &q)
Returns the q inverse.
glm::mediump_dualquat
tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-precision floating-point numbers.
Definition: dual_quaternion.hpp:215
glm::mediump_ddualquat
tdualquat< double, mediump > mediump_ddualquat
Dual-quaternion of medium double-precision floating-point numbers.
Definition: dual_quaternion.hpp:247
glm::mat3x4_cast
GLM_FUNC_DECL tmat3x4< T, P > mat3x4_cast(tdualquat< T, P > const &x)
Converts a quaternion to a 3 * 4 matrix.
glm::lowp_fdualquat
tdualquat< float, lowp > lowp_fdualquat
Dual-quaternion of low single-precision floating-point numbers.
Definition: dual_quaternion.hpp:226
glm::dualquat
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
Definition: dual_quaternion.hpp:259