fbxdualquaternion.h 12 KB

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