fbxvector2.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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 fbxvector2.h
  9. #ifndef _FBXSDK_CORE_MATH_VECTOR_2_H_
  10. #define _FBXSDK_CORE_MATH_VECTOR_2_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/fbxsdk_nsbegin.h>
  13. /** A two double mathematic vector class.
  14. * \nosubgrouping
  15. */
  16. class FBXSDK_DLL FbxVector2 : public FbxDouble2
  17. {
  18. public:
  19. /**
  20. * \name Constructors and Destructor
  21. */
  22. //@{
  23. //! Constructor.
  24. FbxVector2();
  25. /** Copy constructor.
  26. * \param pVector2 The vector copied to this one.
  27. */
  28. FbxVector2(const FbxVector2& pVector2);
  29. /** Constructor.
  30. * \param pX X component.
  31. * \param pY Y component.
  32. */
  33. FbxVector2(double pX, double pY);
  34. //@}
  35. /**
  36. * \name Access
  37. */
  38. //@{
  39. /** Assignment operation.
  40. * \param pVector2 The vector assigned to this one.
  41. * \return This vector after assignment.
  42. */
  43. FbxVector2& operator=(const FbxVector2& pVector2);
  44. /** Set vector.
  45. * \param pX The X component value.
  46. * \param pY The Y component value.
  47. */
  48. void Set(double pX, double pY);
  49. //@}
  50. /**
  51. * \name Scalar Operations
  52. */
  53. //@{
  54. /** Add a value to all vector components.
  55. * \param pValue The value to add to each component of the vector.
  56. * \return A new vector with the result of adding pValue to each component of this vector.
  57. * \remarks The pValue parameter is not checked.
  58. */
  59. FbxVector2 operator+(double pValue) const;
  60. /** Subtract a value from all vector components.
  61. * \param pValue The value to subtract from each component of the vector.
  62. * \return A new vector with the result of subtracting pValue from each component of this vector.
  63. * \remarks The pValue parameter is not checked.
  64. */
  65. FbxVector2 operator-(double pValue) const;
  66. /** Multiply a value to all vector components.
  67. * \param pValue The value multiplying each component of the vector.
  68. * \return A new vector with the result of multiplying each component of this vector by pValue.
  69. * \remarks The pValue parameter is not checked.
  70. */
  71. FbxVector2 operator*(double pValue) const;
  72. /** Divide all vector components by a value.
  73. * \param pValue The value dividing each component of the vector.
  74. * \return A new vector with the result of dividing each component of this vector by pValue.
  75. * \remarks The pValue parameter is not checked.
  76. */
  77. FbxVector2 operator/(double pValue) const;
  78. /** Add a value to all vector components.
  79. * \param pValue The value to add to each component of the vector.
  80. * \return The result of adding pValue to each component of this vector, replacing this vector.
  81. * \remarks The pValue parameter is not checked.
  82. */
  83. FbxVector2& operator+=(double pValue);
  84. /** Subtract a value from all vector components.
  85. * \param pValue The value to subtract from each component of the vector.
  86. * \return The result of subtracting pValue from each component of this vector, replacing this vector.
  87. * \remarks The pValue parameter is not checked.
  88. */
  89. FbxVector2& operator-=(double pValue);
  90. /** Multiply a value to all vector elements.
  91. * \param pValue The value multiplying each component of the vector.
  92. * \return The result of multiplying each component of this vector by pValue, replacing this vector.
  93. * \remarks The pValue parameter is not checked.
  94. */
  95. FbxVector2& operator*=(double pValue);
  96. /** Divide all vector elements by a value.
  97. * \param pValue The value dividing each component of the vector.
  98. * \return The result of multiplying each component of this vector by pValue, replacing this vector.
  99. * \remarks The pValue parameter is not checked.
  100. */
  101. FbxVector2& operator/=(double pValue);
  102. //@}
  103. /**
  104. * \name Vector Operations
  105. */
  106. //@{
  107. /** Unary minus operator.
  108. * \return The vector that is the negation of \c this.
  109. */
  110. FbxVector2 operator-() const;
  111. /** Add two vectors together.
  112. * \param pVector Vector to add.
  113. * \return The result of this vector + pVector.
  114. * \remarks The values in pVector are not checked.
  115. */
  116. FbxVector2 operator+(const FbxVector2& pVector) const;
  117. /** Subtract a vector from another vector.
  118. * \param pVector Vector to subtract.
  119. * \return The result of this vector - pVector.
  120. * \remarks The values in pVector are not checked.
  121. */
  122. FbxVector2 operator-(const FbxVector2& pVector) const;
  123. /** Memberwise multiplication of two vectors.
  124. * \param pVector Multiplying vector.
  125. * \return The result of this vector * pVector.
  126. * \remarks The values in pVector are not checked.
  127. */
  128. FbxVector2 operator*(const FbxVector2& pVector) const;
  129. /** Memberwise division of a vector with another vector.
  130. * \param pVector Dividing vector.
  131. * \return The result of this vector / pVector.
  132. * \remarks The values in pVector are not checked.
  133. */
  134. FbxVector2 operator/(const FbxVector2& pVector) const;
  135. /** Add two vectors together.
  136. * \param pVector Vector to add.
  137. * \return The result of this vector + pVector, replacing this vector.
  138. * \remarks The values in pVector are not checked.
  139. */
  140. FbxVector2& operator+=(const FbxVector2& pVector);
  141. /** Subtract a vector from another vector.
  142. * \param pVector Vector to subtract.
  143. * \return The result of this vector - pVector, replacing this vector.
  144. * \remarks The values in pVector are not checked.
  145. */
  146. FbxVector2& operator-=(const FbxVector2& pVector);
  147. /** Memberwise multiplication of two vectors.
  148. * \param pVector Multiplying vector.
  149. * \return The result of this vector * pVector, replacing this vector.
  150. * \remarks The values in pVector are not checked.
  151. */
  152. FbxVector2& operator*=(const FbxVector2& pVector);
  153. /** Memberwise division of a vector with another vector.
  154. * \param pVector Dividing vector.
  155. * \remarks The values in pVector are not checked.
  156. * \return The result of this vector / pVector, replacing this vector.
  157. * \remarks The values in pVector are not checked.
  158. */
  159. FbxVector2& operator/=(const FbxVector2& pVector);
  160. /** Calculate the dot product of two vectors.
  161. * \param pVector The second vector.
  162. * \return The dot product value.
  163. */
  164. double DotProduct(const FbxVector2& pVector) const;
  165. //@}
  166. /**
  167. * \name Boolean Operations
  168. */
  169. //@{
  170. /** Equivalence operator.
  171. * \param pVector The vector to be compared to \e this.
  172. * \return \c true if the two vectors are equal (each element is within a FBXSDK_TOLERANCE tolerance), \c false otherwise.
  173. */
  174. bool operator==(const FbxVector2 & pVector) const;
  175. /** Non-equivalence operator.
  176. * \param pVector The vector to be compared to \e this.
  177. * \return \c false if the two vectors are equal (each element is within a FBXSDK_TOLERANCE tolerance), \c true otherwise.
  178. */
  179. bool operator!=(const FbxVector2 & pVector) const;
  180. //@}
  181. /**
  182. * \name Length
  183. */
  184. //@{
  185. /** Get the vector's length.
  186. * \return The mathematical length of the vector.
  187. */
  188. double Length() const;
  189. /** Get the vector's length squared.
  190. * \return The mathematical square length of the vector.
  191. */
  192. double SquareLength() const;
  193. /** Find the distance between 2 vectors.
  194. * \param pVector The second vector.
  195. * \return The mathematical distance between the two vectors.
  196. */
  197. double Distance(const FbxVector2& pVector) const;
  198. //! Normalize the vector, length set to 1.
  199. void Normalize();
  200. //@}
  201. /**
  202. * \name Casting
  203. */
  204. //@{
  205. //! Cast the vector in a double pointer.
  206. operator double* ();
  207. //! Cast the vector in a const double pointer.
  208. operator const double* () const;
  209. //@}
  210. /** Find out if the vector is equal to zero.
  211. * \param pSize The number of element to test, starting at beginning. Value must range between [1, 2].
  212. * \return \c true if all elements of the vector are zero, \c false otherwise. */
  213. bool IsZero(int pSize=2) const;
  214. // Fix value like 1.#IND, 1.#INF, nan, and inf
  215. void FixIncorrectValue();
  216. };
  217. #include <fbxsdk/fbxsdk_nsend.h>
  218. #endif /* _FBXSDK_CORE_MATH_VECTOR_2_H_ */