Open Source Tomb Raider Engine
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Vector3d.h 3.5KB

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