1.0.0 API documentation
Loading...
Searching...
No Matches
dual_quaternion.hpp
Go to the documentation of this file.
1
15
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
29namespace 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_CTOR_DECL tdualquat(tdualquat<T, P> const& d);
61
62 // -- Explicit basic constructors --
63
64 GLM_CTOR_DECL tdualquat(qua<T, Q> const& real);
65 GLM_CTOR_DECL tdualquat(qua<T, Q> const& orientation, vec<3, T, Q> const& translation);
66 GLM_CTOR_DECL tdualquat(qua<T, Q> const& real, qua<T, Q> const& dual);
67
68 // -- Conversion constructors --
69
70 template<typename U, qualifier P>
71 GLM_CTOR_DECL GLM_EXPLICIT tdualquat(tdualquat<U, P> const& q);
72
73 GLM_CTOR_DECL GLM_EXPLICIT tdualquat(mat<2, 4, T, Q> const& holder_mat);
74 GLM_CTOR_DECL GLM_EXPLICIT 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_DISCARD_DECL tdualquat<T, Q> & operator=(tdualquat<U, Q> const& m);
82 template<typename U>
83 GLM_FUNC_DISCARD_DECL tdualquat<T, Q> & operator*=(U s);
84 template<typename U>
85 GLM_FUNC_DISCARD_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))
235
240#elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
243#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
246#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
247 typedef lowp_fdualquat dualquat;
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))
259#elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
261#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
263#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
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_FUNC_DECL GLM_CONSTEXPR qua< T, Q > lerp(qua< T, Q > const &x, qua< T, Q > const &y, T a)
Linear interpolation of two quaternions.
GLM_FUNC_DECL GLM_CONSTEXPR qua< T, Q > inverse(qua< T, Q > const &q)
Returns the q inverse.
GLM_FUNC_DECL qua< T, Q > normalize(qua< T, Q > const &q)
Returns the normalized quaternion.
GLM_FUNC_DECL T length(qua< T, Q > const &q)
Returns the norm of a quaternions.
tdualquat< double, mediump > mediump_ddualquat
Dual-quaternion of medium double-qualifier floating-point numbers.
highp_fdualquat fdualquat
Dual-quaternion of single-qualifier floating-point numbers.
highp_ddualquat ddualquat
Dual-quaternion of default double-qualifier floating-point numbers.
tdualquat< float, mediump > mediump_fdualquat
Dual-quaternion of medium single-qualifier floating-point numbers.
tdualquat< float, highp > highp_fdualquat
Dual-quaternion of high single-qualifier floating-point numbers.
GLM_FUNC_DECL tdualquat< T, Q > dual_quat_identity()
Creates an identity dual quaternion.
GLM_FUNC_DECL mat< 3, 4, T, Q > mat3x4_cast(tdualquat< T, Q > 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, highp > highp_dualquat
Dual-quaternion of high single-qualifier floating-point numbers.
tdualquat< float, lowp > lowp_fdualquat
Dual-quaternion of low single-qualifier floating-point numbers.
tdualquat< float, mediump > mediump_dualquat
Dual-quaternion of medium single-qualifier floating-point numbers.
tdualquat< double, lowp > lowp_ddualquat
Dual-quaternion of low double-qualifier floating-point numbers.
GLM_FUNC_DECL tdualquat< T, Q > dualquat_cast(mat< 2, 4, T, Q > const &x)
Converts a 2 * 4 matrix (matrix which holds real and dual parts) to a quaternion.
GLM_FUNC_DECL mat< 2, 4, T, Q > mat2x4_cast(tdualquat< T, Q > const &x)
Converts a quaternion to a 2 * 4 matrix.
tdualquat< float, lowp > lowp_dualquat
Dual-quaternion of low single-qualifier floating-point numbers.
highp_fdualquat dualquat
Dual-quaternion of floating-point numbers.
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.