GLM 0.9.5

- Main Page
- Related Pages
- Modules
- Namespaces
- Files

- File List

dual_quaternion.hpp
Go to the documentation of this file.
1
41 #ifndef GLM_GTX_dual_quaternion
42 #define GLM_GTX_dual_quaternion
43
44 // Dependency:
45 #include "../glm.hpp"
46 #include "../gtc/constants.hpp"
47 #include "../gtc/quaternion.hpp"
48
49 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
50 # pragma message("GLM: GLM_GTX_dual_quaternion extension included")
51 #endif
52
53 namespace glm{
54 namespace detail
55 {
56 template <typename T, precision P>
57 struct tdualquat
58 {
59 enum ctor{null};
60
61 typedef glm::detail::tquat<T, P> part_type;
62
63 public:
64 glm::detail::tquat<T, P> real, dual;
65
66 GLM_FUNC_DECL GLM_CONSTEXPR int length() const;
67
68 // Constructors
69 tdualquat();
70 explicit tdualquat(tquat<T, P> const & real);
71 tdualquat(tquat<T, P> const & real,tquat<T, P> const & dual);
72 tdualquat(tquat<T, P> const & orientation,tvec3<T, P> const& translation);
73
75 // tdualquat conversions
76 explicit tdualquat(tmat2x4<T, P> const & holder_mat);
77 explicit tdualquat(tmat3x4<T, P> const & aug_mat);
78
79 // Accesses
80 part_type & operator[](int i);
81 part_type const & operator[](int i) const;
82
83 // Operators
84 tdualquat<T, P> & operator*=(T const & s);
85 tdualquat<T, P> & operator/=(T const & s);
86 };
87
88 template <typename T, precision P>
89 detail::tquat<T, P> operator- (
90 detail::tquat<T, P> const & q);
91
92 template <typename T, precision P>
93 detail::tdualquat<T, P> operator+ (
94 detail::tdualquat<T, P> const & q,
95 detail::tdualquat<T, P> const & p);
96
97 template <typename T, precision P>
98 detail::tdualquat<T, P> operator* (
99 detail::tdualquat<T, P> const & q,
100 detail::tdualquat<T, P> const & p);
101
102 template <typename T, precision P>
103 detail::tvec3<T, P> operator* (
104 detail::tquat<T, P> const & q,
105 detail::tvec3<T, P> const & v);
106
107 template <typename T, precision P>
108 detail::tvec3<T, P> operator* (
109 detail::tvec3<T, P> const & v,
110 detail::tquat<T, P> const & q);
111
112 template <typename T, precision P>
113 detail::tvec4<T, P> operator* (
114 detail::tquat<T, P> const & q,
115 detail::tvec4<T, P> const & v);
116
117 template <typename T, precision P>
118 detail::tvec4<T, P> operator* (
119 detail::tvec4<T, P> const & v,
120 detail::tquat<T, P> const & q);
121
122 template <typename T, precision P>
123 detail::tdualquat<T, P> operator* (
124 detail::tdualquat<T, P> const & q,
125 T const & s);
126
127 template <typename T, precision P>
128 detail::tdualquat<T, P> operator* (
129 T const & s,
130 detail::tdualquat<T, P> const & q);
131
132 template <typename T, precision P>
133 detail::tdualquat<T, P> operator/ (
134 detail::tdualquat<T, P> const & q,
135 T const & s);
136 } //namespace detail
137
140
144 template <typename T, precision P>
145 detail::tdualquat<T, P> normalize(
146 detail::tdualquat<T, P> const & q);
147
151 template <typename T, precision P>
152 detail::tdualquat<T, P> lerp(
153 detail::tdualquat<T, P> const & x,
154 detail::tdualquat<T, P> const & y,
155 T const & a);
156
160 template <typename T, precision P>
161 detail::tdualquat<T, P> inverse(
162 detail::tdualquat<T, P> const & q);
163
164 /*
169 template <typename T, precision P>
170 detail::tmat3x3<T, P> mat3_cast(
171 detail::tdualquat<T, P> const & x);
172 */
173
177 template <typename T, precision P>
178 detail::tmat2x4<T, P> mat2x4_cast(
179 detail::tdualquat<T, P> const & x);
180
184 template <typename T, precision P>
185 detail::tmat3x4<T, P> mat3x4_cast(
186 detail::tdualquat<T, P> const & x);
187
191 template <typename T, precision P>
192 detail::tdualquat<T, P> dualquat_cast(
193 detail::tmat2x4<T, P> const & x);
194
198 template <typename T, precision P>
199 detail::tdualquat<T, P> dualquat_cast(
200 detail::tmat3x4<T, P> const & x);
201
202
206 typedef detail::tdualquat<float, lowp> lowp_dualquat;
207
211 typedef detail::tdualquat<float, mediump> mediump_dualquat;
212
216 typedef detail::tdualquat<float, highp> highp_dualquat;
217
218
222 typedef detail::tdualquat<float, lowp> lowp_fdualquat;
223
227 typedef detail::tdualquat<float, mediump> mediump_fdualquat;
228
232 typedef detail::tdualquat<float, highp> highp_fdualquat;
233
234
238 typedef detail::tdualquat<double, lowp> lowp_ddualquat;
239
243 typedef detail::tdualquat<double, mediump> mediump_ddualquat;
244
248 typedef detail::tdualquat<double, highp> highp_ddualquat;
249
250
251 #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
252 typedef highp_fdualquat dualquat;
256
260 typedef highp_fdualquat fdualquat;
261 #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
262 typedef highp_fdualquat dualquat;
263 typedef highp_fdualquat fdualquat;
264 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
265 typedef mediump_fdualquat dualquat;
266 typedef mediump_fdualquat fdualquat;
267 #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
268 typedef lowp_fdualquat dualquat;
269 typedef lowp_fdualquat fdualquat;
270 #else
271 # error "GLM error: multiple default precision requested for single-precision floating-point types"
272 #endif
273
274
275 #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
276 typedef highp_ddualquat ddualquat;
280 #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
281 typedef highp_ddualquat ddualquat;
282 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
283 typedef mediump_ddualquat ddualquat;
284 #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
285 typedef lowp_ddualquat ddualquat;
286 #else
287 # error "GLM error: Multiple default precision requested for double-precision floating-point types"
288 #endif
289
291 } //namespace glm
292
293 #include "dual_quaternion.inl"
294
295 #endif//GLM_GTX_dual_quaternion
glm::highp_dualquat
detail::tdualquat< float, highp > highp_dualquat
Dual-quaternion of high single-precision floating-point numbers.
Definition: dual_quaternion.hpp:216
glm::lerp
GLM_FUNC_DECL detail::tquat< T, P > lerp(detail::tquat< T, P > const &x, detail::tquat< T, P > const &y, T const &a)
Linear interpolation of two quaternions.
glm::mat3x4_cast
detail::tmat3x4< T, P > mat3x4_cast(detail::tdualquat< T, P > const &x)
Converts a quaternion to a 3 * 4 matrix.
glm::highp_ddualquat
detail::tdualquat< double, highp > highp_ddualquat
Dual-quaternion of high double-precision floating-point numbers.
Definition: dual_quaternion.hpp:248
glm::fdualquat
highp_fdualquat fdualquat
Dual-quaternion of single-precision floating-point numbers.
Definition: dual_quaternion.hpp:260
glm::lowp_ddualquat
detail::tdualquat< double, lowp > lowp_ddualquat
Dual-quaternion of low double-precision floating-point numbers.
Definition: dual_quaternion.hpp:238
glm::orientation
detail::tmat4x4< T, P > orientation(detail::tvec3< T, P > const &Normal, detail::tvec3< T, P > const &Up)
Build a rotation matrix from a normal and a up vector.
glm::normalize
GLM_FUNC_DECL genType normalize(genType const &x)
Returns a vector in the same direction as x but with length of 1.
glm::mediump_ddualquat
detail::tdualquat< double, mediump > mediump_ddualquat
Dual-quaternion of medium double-precision floating-point numbers.
Definition: dual_quaternion.hpp:243
glm::lowp_dualquat
detail::tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-precision floating-point numbers.
Definition: dual_quaternion.hpp:206
glm::length
GLM_FUNC_DECL genType::value_type length(genType const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::inverse
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)
Return the inverse of a squared matrix.
glm::dualquat_cast
detail::tdualquat< T, P > dualquat_cast(detail::tmat2x4< T, P > const &x)
Converts a 2 * 4 matrix (matrix which holds real and dual parts) to a quaternion. ...
glm::ddualquat
highp_ddualquat ddualquat
Dual-quaternion of default double-precision floating-point numbers.
Definition: dual_quaternion.hpp:279
glm::mat2x4_cast
detail::tmat2x4< T, P > mat2x4_cast(detail::tdualquat< T, P > const &x)
Converts a quaternion to a 2 * 4 matrix.
glm::mediump_fdualquat
detail::tdualquat< float, mediump > mediump_fdualquat
Dual-quaternion of medium single-precision floating-point numbers.
Definition: dual_quaternion.hpp:227
glm::lowp_fdualquat
detail::tdualquat< float, lowp > lowp_fdualquat
Dual-quaternion of low single-precision floating-point numbers.
Definition: dual_quaternion.hpp:222
glm::highp_fdualquat
detail::tdualquat< float, highp > highp_fdualquat
Dual-quaternion of high single-precision floating-point numbers.
Definition: dual_quaternion.hpp:232
glm::mediump_dualquat
detail::tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-precision floating-point numbers.
Definition: dual_quaternion.hpp:211
glm::dualquat
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
Definition: dual_quaternion.hpp:255