1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxdualquaternion.h
13#ifndef _FBXSDK_CORE_MATH_DUAL_QUATERNION_H_
14#define _FBXSDK_CORE_MATH_DUAL_QUATERNION_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/core/math/fbxquaternion.h>
19
20#include <fbxsdk/fbxsdk_nsbegin.h>
21
22/** FBX SDK dual quaternion class to represent rigid transformation, which is combined by two quaternions.
23 * A transformation is said to be rigid if it preserves relative distances and angles.
24 * That means rotation and translation.
25 * \nosubgrouping
26 */
27class FBXSDK_DLL FbxDualQuaternion
28{
29public:
30 /**
31 * \name Constructors and Destructor
32 */
33 //@{
34 //! Constructor.
35 FbxDualQuaternion();
36
37 /** Constructor.
38 * \param pV1 FbxQuaternion object.
39 * \param pV2 FbxQuaternion object.
40 */
41 FbxDualQuaternion(const FbxQuaternion& pV1, const FbxQuaternion& pV2);
42
43 /** Copy constructor.
44 * \param pV FbxQuaternion object copied to this one.
45 */
46 FbxDualQuaternion(const FbxDualQuaternion& pV);
47
48 /** Constructor.
49 * \param pRotation The rotation the dual quaternion is going to represent.
50 * \param pTranslation The translation the dual quaternion is going to represent.
51 */
52 FbxDualQuaternion(const FbxQuaternion& pRotation, const FbxVector4& pTranslation);
53
54 /** Constructor.
55 * \param pX1 The X component of the first quaternion.
56 * \param pY1 The Y component of the first quaternion.
57 * \param pZ1 The Z component of the first quaternion.
58 * \param pW1 The W component of the first quaternion.
59 * \param pX2 The X component of the second quaternion.
60 * \param pY2 The Y component of the second quaternion.
61 * \param pZ2 The Z component of the second quaternion.
62 * \param pW2 The W component of the second quaternion.
63 */
64 FbxDualQuaternion(double pX1, double pY1, double pZ1, double pW1, double pX2, double pY2, double pZ2, double pW2);
65
66 //! Destructor.
67 ~FbxDualQuaternion();
68 //@}
69
70 /**
71 * \name Access
72 */
73 //@{
74 /** Assignment operation.
75 * \param pDualQuaternion FbxDualQuaternion object assigned to this one.
76 */
77 FbxDualQuaternion& operator=(const FbxDualQuaternion& pDualQuaternion);
78
79 /** Set vector.
80 * \param pX1 The X component of the first quaternion.
81 * \param pY1 The Y component of the first quaternion.
82 * \param pZ1 The Z component of the first quaternion.
83 * \param pW1 The W component of the first quaternion.
84 * \param pX2 The X component of the second quaternion.
85 * \param pY2 The Y component of the second quaternion.
86 * \param pZ2 The Z component of the second quaternion.
87 * \param pW2 The W component of the second quaternion.
88 */
89 void Set(double pX1, double pY1, double pZ1, double pW1, double pX2, double pY2, double pZ2, double pW2);
90
91 /** Get the first quaternion of the dual quaternion.
92 * \return The first quaternion of the dual quaternion.
93 */
94 FbxQuaternion& GetFirstQuaternion();
95
96 /** Get the second quaternion of the dual quaternion.
97 * \return The second quaternion of the dual quaternion.
98 */
99 FbxQuaternion& GetSecondQuaternion();
100
101 /** Get the first quaternion of the dual quaternion.
102 * \return The first quaternion of the dual quaternion.
103 */
104 const FbxQuaternion& GetFirstQuaternion() const;
105
106 /** Get the second quaternion of the dual quaternion.
107 * \return The second quaternion of the dual quaternion.
108 */
109 const FbxQuaternion& GetSecondQuaternion() const;
110
111 /** Get the rotation part from the dual quaternion.
112 * \return FbxQuaternion object to represent rotation.
113 */
114 FbxQuaternion GetRotation() const;
115
116 /** Get the translation part from the dual quaternion.
117 * \return FbxVector4 object to represent translation.
118 * \remarks A dual quaternion can represent rotation followed by translation, or translation followed by rotation.
119 * This method assumes that the rotation is expressed first, followed by translation, as is done by most DCC tools.
120 */
121 FbxVector4 GetTranslation() const;
122 //@}
123
124 /**
125 * \name Scalar Operations
126 */
127 //@{
128 /** Add a value to all vector components.
129 * \param pValue The value to add to each component of the vector.
130 * \return New vector.
131 * \remarks The passed value is not checked.
132 */
133 FbxDualQuaternion operator+(double pValue) const;
134
135 /** Subtract a value from all vector components.
136 * \param pValue The value to subtract from each component of the vector.
137 * \return New vector.
138 * \remarks The passed value is not checked.
139 */
140 FbxDualQuaternion operator-(double pValue) const;
141
142 /** Multiply all vector components by a value.
143 * \param pValue The value multiplying each component of the vector.
144 * \return New vector.
145 * \remarks The passed value is not checked.
146 */
147 FbxDualQuaternion operator*(double pValue) const;
148
149 /** Divide all vector components by a value.
150 * \param pValue The value dividing each component of the vector.
151 * \return New vector.
152 * \remarks The passed value is not checked.
153 */
154 FbxDualQuaternion operator/(double pValue) const;
155
156 /** Add a value to all vector components.
157 * \param pValue The value to add to each component of the vector.
158 * \return The result of adding pValue to each component of the vector, replacing this dual quaternion.
159 * \remarks The passed value is not checked.
160 */
161 FbxDualQuaternion& operator+=(double pValue);
162
163 /** Subtract a value from all vector components.
164 * \param pValue The value to subtract from each component of the vector.
165 * \return The result of subtracting pValue from each component of the vector, replacing this dual quaternion.
166 * \remarks The passed value is not checked.
167 */
168 FbxDualQuaternion& operator-=(double pValue);
169
170 /** Multiply a value to all vector elements.
171 * \param pValue The value multiplying each component of the vector.
172 * \return The result of multiplying each component of the vector by pValue, replacing this dual quaternion.
173 * \remarks The passed value is not checked.
174 */
175 FbxDualQuaternion& operator*=(double pValue);
176
177 /** Divide all vector elements by a value.
178 * \param pValue The value dividing each component of the vector.
179 * \return The result of dividing each component of the vector by pValue, replacing this dual quaternion.
180 * \remarks The passed value is not checked.
181 */
182 FbxDualQuaternion& operator/=(double pValue);
183 //@}
184
185 /**
186 * \name Vector Operations
187 */
188 //@{
189 /** Unary minus operator.
190 * \return A dual quaternion where each component is multiplied by -1.
191 */
192 FbxDualQuaternion operator-() const;
193
194 /** Add two vectors together.
195 * \param pDualQuaternion Dual quaternion to add.
196 * \return The dual quaternion v' = this + pDualQuaternion.
197 * \remarks The values in pDualQuaternion are not checked.
198 */
199 FbxDualQuaternion operator+(const FbxDualQuaternion& pDualQuaternion) const;
200
201 /** Subtract a quaternion from another quaternion.
202 * \param pDualQuaternion Dual quaternion to subtract.
203 * \return The dual quaternion v' = this - pDualQuaternion.
204 * \remarks The values in pDualQuaternion are not checked.
205 */
206 FbxDualQuaternion operator-(const FbxDualQuaternion& pDualQuaternion) const;
207
208 /** Memberwise multiplication of two vectors.
209 * \param pDualQuaternion Multiplying dual quaternion.
210 * \return The dual quaternion v' = this * pQuaternion.
211 * \remarks The values in pDualQuaternion are not checked.
212 */
213 FbxDualQuaternion operator*(const FbxDualQuaternion& pDualQuaternion) const;
214
215 /** Memberwise division of a dual quaternion with another dual quaternion.
216 * \param pDualQuaternion Dividing dual quaternion.
217 * \return The dual quaternion v' = this / pQuaternion.
218 * \remarks The values in pDualQuaternion are not checked.
219 */
220 FbxDualQuaternion operator/(const FbxDualQuaternion& pDualQuaternion) const;
221
222 /** Add two quaternions together.
223 * \param pDualQuaternion Dual quaternion to add.
224 * \return The dual quaternion v' = this + pQuaternion, replacing this dual quaternion.
225 * \remarks The values in pDualQuaternion are not checked.
226 */
227 FbxDualQuaternion& operator+=(const FbxDualQuaternion& pDualQuaternion);
228
229 /** Subtract a dual quaternion from another vector.
230 * \param pDualQuaternion Dual quaternion to subtract.
231 * \return The dual quaternion v' = this - pQuaternion, replacing this dual quaternion.
232 * \remarks The values in pDualQuaternion are not checked.
233 */
234 FbxDualQuaternion& operator-=(const FbxDualQuaternion& pDualQuaternion);
235
236 /** Memberwise multiplication of two quaternions.
237 * \param pDualQuaternion Multiplying dual quaternion.
238 * \return The dual quaternion v' = this * pQuaternion, replacing this dual quaternion.
239 * \remarks The values in pDualQuaternion are not checked.
240 */
241 FbxDualQuaternion& operator*=(const FbxDualQuaternion& pDualQuaternion);
242
243 /** Memberwise division of a dual quaternion by another dual quaternion.
244 * \param pDualQuaternion Dividing dual quaternion.
245 * \return The dual quaternion v' = this / pQuaternion, replacing this dual quaternion.
246 * \remarks The values in pDualQuaternion are not checked.
247 */
248 FbxDualQuaternion& operator/=(const FbxDualQuaternion& pDualQuaternion);
249
250 /** Multiplication of a dual quaternion by a FbxVector4.
251 * \param pVector The FbxVector4 to multiply with.
252 * \return The dual quaternion v' = FbxDualQuaternion(mQ1, (mQ1 * pVector) + mQ2).
253 * \remarks The values in pDualQuaternion are not checked.
254 */
255 FbxDualQuaternion operator*(const FbxVector4 pVector) const;
256
257 /** Return dual quaternion product.
258 * \param pDualQuaternion Product dual quaternion.
259 * \return The dual quaternion that is the product of this and pDualQuaternion.
260 */
261 FbxDualQuaternion Product(const FbxDualQuaternion& pDualQuaternion) const;
262
263 /** Normalize the dual quaternion, length set to 1.
264 */
265 void Normalize();
266
267 /** Calculate the dual quaternion's inverse.
268 * \return The inverse of this dual quaternion.
269 */
270 void Inverse();
271
272 /** Deform a point by this dual quaternion.
273 * \return The inverse of this quaternion.
274 */
275 FbxVector4 Deform(FbxVector4& pPoint);
276 //@}
277
278 /**
279 * \name Conjugate Operations
280 * \brief Dual quaternion has three types of conjugate.
281 */
282 //@{
283 /** Conjugate both quaternions of this dual quaternion.
284 */
285 void Conjugate();
286
287 /** Conjugate in dual space.
288 */
289 void Dual();
290
291 /** Conjugate both quaternions of this dual quaternion in dual space.
292 */
293 void DualConjugate();
294 //@}
295
296 /**
297 * \name Boolean Operations
298 */
299 //@{
300 /** Equivalence operator.
301 * \param pV The quaternion to be compared to this quaternion.
302 * \return \c true if the two quaternions are equal (each element is within a FBXSDK_TOLERANCE tolerance), \c false otherwise.
303 */
304 bool operator==(const FbxDualQuaternion & pV) const;
305
306 /** Non equivalence operator.
307 * \param pV The quaternion to be compared to \e this.
308 * \return \c false if the two quaternions are equal (each element is within a FBXSDK_TOLERANCE tolerance), \c true otherwise.
309 */
310 bool operator!=(const FbxDualQuaternion & pV) const;
311 //@}
312
313/*****************************************************************************************************************************
314** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
315*****************************************************************************************************************************/
316#ifndef DOXYGEN_SHOULD_SKIP_THIS
317private:
318 FbxQuaternion mQ1;
319 FbxQuaternion mQ2;
320#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
321};
322
323#include <fbxsdk/fbxsdk_nsend.h>
324
325#endif /* _FBXSDK_CORE_MATH_DUAL_QUATERNION_H_ */
326