Open Source Tomb Raider Engine
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*!
  2. * \file include/Vector3d.h
  3. * \brief 3D Math vector
  4. *
  5. * \author Mongoose
  6. */
  7. #ifndef _VECTOR3D_H_
  8. #define _VECTOR3D_H_
  9. #include "utils/math.h"
  10. /*!
  11. * \brief 3D Math Vector
  12. */
  13. class Vector3d {
  14. public:
  15. /*!
  16. * \brief Constructs an object of Vector3d
  17. */
  18. Vector3d();
  19. /*!
  20. * \brief Constructs an object of Vector3d
  21. * \param v data to load into new Vector3d
  22. */
  23. Vector3d(vec3_t v);
  24. /*!
  25. * \brief Constructs an object of Vector3d
  26. * \param x X part of new Vector3d
  27. * \param y Y part of new Vector3d
  28. * \param z Z part of new Vector3d
  29. */
  30. Vector3d(vec_t x, vec_t y, vec_t z);
  31. /*!
  32. * \brief Deconstructs an object of Vector3d
  33. */
  34. ~Vector3d();
  35. /*!
  36. * \brief Calculate dot product
  37. * \param u first argument
  38. * \param v second argument
  39. * \returns dot product of u and v vectors
  40. */
  41. static vec_t dot(const Vector3d &u, const Vector3d &v);
  42. /*!
  43. * \brief Calculate cross product
  44. * \param u first argument
  45. * \param v second argument
  46. * \returns cross product of u and v vectors
  47. */
  48. static Vector3d cross(const Vector3d &u, const Vector3d &v);
  49. /*!
  50. * \brief Get Magnitude
  51. * \returns magnitude of this vector
  52. */
  53. vec_t magnitude();
  54. /*!
  55. * \brief Normalize
  56. * \returns normalized copy of this vector
  57. */
  58. Vector3d unit();
  59. /*!
  60. * \brief Get the Zero vector
  61. * \returns (0, 0, 0) vector
  62. */
  63. static Vector3d zeroVector();
  64. /*!
  65. * \brief Add to this vector
  66. * \param v addend
  67. * \returns a vector = this vector + v
  68. */
  69. Vector3d operator +(const Vector3d &v);
  70. /*!
  71. * \brief Subtract from this vector
  72. * \param v subtrahend
  73. * \returns a vector = this vector - v
  74. */
  75. Vector3d operator -(const Vector3d &v);
  76. /*!
  77. * \brief Negate this vector
  78. * \returns a copy of this vector, negated
  79. */
  80. Vector3d operator -();
  81. /*!
  82. * \brief Scale this vector
  83. * \param s scaling factor
  84. * \returns this vector multiplied with s
  85. */
  86. Vector3d operator *(vec_t s);
  87. /*!
  88. * \brief Scale this vactor
  89. * \param s inverse scaling factor
  90. * \returns this vector divided by s
  91. */
  92. Vector3d operator /(vec_t s);
  93. /*!
  94. * \brief Dot product this vector
  95. * \param v second vector for dot product
  96. * \returns dot product of V by this vector
  97. */
  98. vec_t operator *(const Vector3d &v);
  99. /*!
  100. * \brief Normalizes this vector
  101. */
  102. void normalize();
  103. /*!
  104. * \brief Set this vector to Zero (0, 0, 0)
  105. */
  106. void zero();
  107. /*!
  108. * \brief Set this vector
  109. * \param v what this vector will be set to
  110. * \returns this vector, now equal to v
  111. */
  112. Vector3d &operator =(const Vector3d &v);
  113. /*!
  114. * \brief Add to this vector, in place
  115. * \param v what will be added to this vector
  116. * \returns this vector, with v added
  117. */
  118. Vector3d &operator +=(const Vector3d &v);
  119. /*!
  120. * \brief Subtract from this vector, in place
  121. * \param v what will be subtracted from this vector
  122. * \returns this vector, with v subtracted
  123. */
  124. Vector3d &operator -=(const Vector3d &v);
  125. /*!
  126. * \brief Scale this vector, in place
  127. * \param s scaling factor
  128. * \returns this vactor multiplied by s
  129. */
  130. Vector3d &operator *=(vec_t s);
  131. vec3_t mVec; //!< Vector data
  132. };
  133. #endif