1.0.0 API documentation: dual_quaternion.hpp Source File

| 1.0.0 API documentation

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 #elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
26 # pragma message("GLM: GLM_GTX_dual_quaternion extension included")
27 #endif
28
29 namespace glm
30 {
33
34 template<typename T, qualifier Q = defaultp>
35 struct tdualquat
36 {
37 // -- Implementation detail --
38
39 typedef T value_type;
40 typedef qua<T, Q> part_type;
41
42 // -- Data --
43
44 qua<T, Q> real, dual;
45
46 // -- Component accesses --
47
48 typedef length_t length_type;
50 GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 2;}
51
52 GLM_FUNC_DECL part_type & operator[](length_type i);
53 GLM_FUNC_DECL part_type const& operator[](length_type i) const;
54
55 // -- Implicit basic constructors --
56
57 GLM_DEFAULTED_FUNC_DECL GLM_CONSTEXPR tdualquat() GLM_DEFAULT;
58 GLM_DEFAULTED_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, Q> const& d) GLM_DEFAULT;
59 template<qualifier P>
60 GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, P> const& d);
61
62 // -- Explicit basic constructors --
63
64 GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real);
65 GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& orientation, vec<3, T, Q> const& translation);
66 GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real, qua<T, Q> const& dual);
67
68 // -- Conversion constructors --
69
70 template<typename U, qualifier P>
71 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tdualquat(tdualquat<U, P> const& q);
72
73 GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<2, 4, T, Q> const& holder_mat);
74 GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<3, 4, T, Q> const& aug_mat);
75
76 // -- Unary arithmetic operators --
77
78 GLM_DEFAULTED_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<T, Q> const& m) GLM_DEFAULT;
79
80 template<typename U>
81 GLM_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<U, Q> const& m);
82 template<typename U>
83 GLM_FUNC_DECL tdualquat<T, Q> & operator*=(U s);
84 template<typename U>
85 GLM_FUNC_DECL tdualquat<T, Q> & operator/=(U s);
86 };
87
88 // -- Unary bit operators --
89
90 template<typename T, qualifier Q>
91 GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q);
92
93 template<typename T, qualifier Q>
94 GLM_FUNC_DECL tdualquat<T, Q> operator-(tdualquat<T, Q> const& q);
95
96 // -- Binary operators --
97
98 template<typename T, qualifier Q>
99 GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p);
100
101 template<typename T, qualifier Q>
102 GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p);
103
104 template<typename T, qualifier Q>
105 GLM_FUNC_DECL vec<3, T, Q> operator*(tdualquat<T, Q> const& q, vec<3, T, Q> const& v);
106
107 template<typename T, qualifier Q>
108 GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v, tdualquat<T, Q> const& q);
109
110 template<typename T, qualifier Q>
111 GLM_FUNC_DECL vec<4, T, Q> operator*(tdualquat<T, Q> const& q, vec<4, T, Q> const& v);
112
113 template<typename T, qualifier Q>
114 GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q> const& v, tdualquat<T, Q> const& q);
115
116 template<typename T, qualifier Q>
117 GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, T const& s);
118
119 template<typename T, qualifier Q>
120 GLM_FUNC_DECL tdualquat<T, Q> operator*(T const& s, tdualquat<T, Q> const& q);
121
122 template<typename T, qualifier Q>
123 GLM_FUNC_DECL tdualquat<T, Q> operator/(tdualquat<T, Q> const& q, T const& s);
124
125 // -- Boolean operators --
126
127 template<typename T, qualifier Q>
128 GLM_FUNC_DECL bool operator==(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2);
129
130 template<typename T, qualifier Q>
131 GLM_FUNC_DECL bool operator!=(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2);
132
136 template <typename T, qualifier Q>
137 GLM_FUNC_DECL tdualquat<T, Q> dual_quat_identity();
138
142 template<typename T, qualifier Q>
143 GLM_FUNC_DECL tdualquat<T, Q> normalize(tdualquat<T, Q> const& q);
144
148 template<typename T, qualifier Q>
149 GLM_FUNC_DECL tdualquat<T, Q> lerp(tdualquat<T, Q> const& x, tdualquat<T, Q> const& y, T const& a);
150
154 template<typename T, qualifier Q>
155 GLM_FUNC_DECL tdualquat<T, Q> inverse(tdualquat<T, Q> const& q);
156
160 template<typename T, qualifier Q>
161 GLM_FUNC_DECL mat<2, 4, T, Q> mat2x4_cast(tdualquat<T, Q> const& x);
162
166 template<typename T, qualifier Q>
167 GLM_FUNC_DECL mat<3, 4, T, Q> mat3x4_cast(tdualquat<T, Q> const& x);
168
172 template<typename T, qualifier Q>
173 GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<2, 4, T, Q> const& x);
174
178 template<typename T, qualifier Q>
179 GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<3, 4, T, Q> const& x);
180
181
185 typedef tdualquat<float, lowp> lowp_dualquat;
186
190 typedef tdualquat<float, mediump> mediump_dualquat;
191
195 typedef tdualquat<float, highp> highp_dualquat;
196
197
201 typedef tdualquat<float, lowp> lowp_fdualquat;
202
206 typedef tdualquat<float, mediump> mediump_fdualquat;
207
211 typedef tdualquat<float, highp> highp_fdualquat;
212
213
217 typedef tdualquat<double, lowp> lowp_ddualquat;
218
222 typedef tdualquat<double, mediump> mediump_ddualquat;
223
227 typedef tdualquat<double, highp> highp_ddualquat;
228
229
230 #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
231 typedef highp_fdualquat dualquat;
235
239 typedef highp_fdualquat fdualquat;
240 #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
241 typedef highp_fdualquat dualquat;
242 typedef highp_fdualquat fdualquat;
243 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
244 typedef mediump_fdualquat dualquat;
245 typedef mediump_fdualquat fdualquat;
246 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
247 typedef lowp_fdualquat dualquat;
248 typedef lowp_fdualquat fdualquat;
249 #else
250 # error "GLM error: multiple default precision requested for single-precision floating-point types"
251 #endif
252
253
254 #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
255 typedef highp_ddualquat ddualquat;
259 #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
260 typedef highp_ddualquat ddualquat;
261 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
262 typedef mediump_ddualquat ddualquat;
263 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
264 typedef lowp_ddualquat ddualquat;
265 #else
266 # error "GLM error: Multiple default precision requested for double-precision floating-point types"
267 #endif
268
270 } //namespace glm
271
272 #include "dual_quaternion.inl"
glm::highp_ddualquat
tdualquat< double, highp > highp_ddualquat
Dual-quaternion of high double-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:227
glm::highp_fdualquat
tdualquat< float, highp > highp_fdualquat
Dual-quaternion of high single-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:211
glm::fdualquat
highp_fdualquat fdualquat
Dual-quaternion of single-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:239
glm::normalize
GLM_FUNC_DECL tdualquat< T, Q > normalize(tdualquat< T, Q > const &q)
Returns the normalized quaternion.
glm::mediump_dualquat
tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:190
glm::dual_quat_identity
GLM_FUNC_DECL tdualquat< T, Q > dual_quat_identity()
Creates an identity dual quaternion.
glm::mat3x4_cast
GLM_FUNC_DECL mat< 3, 4, T, Q > mat3x4_cast(tdualquat< T, Q > const &x)
Converts a quaternion to a 3 * 4 matrix.
glm::mediump_fdualquat
tdualquat< float, mediump > mediump_fdualquat
Dual-quaternion of medium single-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:206
glm::dualquat_cast
GLM_FUNC_DECL tdualquat< T, Q > dualquat_cast(mat< 3, 4, T, Q > const &x)
Converts a 3 * 4 matrix (augmented matrix rotation + translation) to a quaternion.
glm::lowp_dualquat
tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:185
glm::length
GLM_FUNC_DECL T length(qua< T, Q > const &q)
Returns the norm of a quaternions.
glm::dualquat
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
Definition: dual_quaternion.hpp:234
glm::orientation
GLM_FUNC_DECL mat< 4, 4, T, Q > orientation(vec< 3, T, Q > const &Normal, vec< 3, T, Q > const &Up)
Build a rotation matrix from a normal and a up vector.
glm::lowp_ddualquat
tdualquat< double, lowp > lowp_ddualquat
Dual-quaternion of low double-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:217
glm::mediump_ddualquat
tdualquat< double, mediump > mediump_ddualquat
Dual-quaternion of medium double-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:222
glm::highp_dualquat
tdualquat< float, highp > highp_dualquat
Dual-quaternion of high single-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:195
glm::ddualquat
highp_ddualquat ddualquat
Dual-quaternion of default double-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:258
glm::lowp_fdualquat
tdualquat< float, lowp > lowp_fdualquat
Dual-quaternion of low single-qualifier floating-point numbers.
Definition: dual_quaternion.hpp:201
glm::lerp
GLM_FUNC_DECL tdualquat< T, Q > lerp(tdualquat< T, Q > const &x, tdualquat< T, Q > const &y, T const &a)
Returns the linear interpolation of two dual quaternion.
glm::mat2x4_cast
GLM_FUNC_DECL mat< 2, 4, T, Q > mat2x4_cast(tdualquat< T, Q > const &x)
Converts a quaternion to a 2 * 4 matrix.
glm::inverse
GLM_FUNC_DECL tdualquat< T, Q > inverse(tdualquat< T, Q > const &q)
Returns the q inverse.