Vector2.pkg 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. $#include "Math/Vector2.h"
  2. class Vector2
  3. {
  4. Vector2();
  5. Vector2(const Vector2& vector);
  6. Vector2(const IntVector2& vector);
  7. Vector2(float x, float y);
  8. ~Vector2();
  9. bool operator ==(const Vector2& rhs) const;
  10. Vector2 operator + (const Vector2& rhs) const;
  11. Vector2 operator - () const;
  12. Vector2 operator - (const Vector2& rhs) const;
  13. Vector2 operator * (float rhs) const;
  14. Vector2 operator * (const Vector2& rhs) const;
  15. Vector2 operator / (float rhs) const;
  16. Vector2 operator / (const Vector2& rhs) const;
  17. void Normalize();
  18. float Length() const;
  19. float LengthSquared() const;
  20. float DotProduct(const Vector2& rhs) const;
  21. float AbsDotProduct(const Vector2& rhs) const;
  22. float ProjectOntoAxis(const Vector2& axis) const;
  23. float Angle(const Vector2& rhs) const;
  24. Vector2 Abs() const;
  25. Vector2 Lerp(const Vector2& rhs, float t) const;
  26. bool Equals(const Vector2& rhs) const;
  27. bool IsNaN() const;
  28. Vector2 Normalized() const;
  29. String ToString() const;
  30. float x_ @ x;
  31. float y_ @ y;
  32. static const Vector2 ZERO;
  33. static const Vector2 LEFT;
  34. static const Vector2 RIGHT;
  35. static const Vector2 UP;
  36. static const Vector2 DOWN;
  37. static const Vector2 ONE;
  38. };
  39. class IntVector2
  40. {
  41. IntVector2();
  42. IntVector2(int x, int y);
  43. IntVector2(const IntVector2& rhs);
  44. ~IntVector2();
  45. bool operator ==(const IntVector2& rhs) const;
  46. IntVector2 operator + (const IntVector2& rhs) const;
  47. IntVector2 operator - () const;
  48. IntVector2 operator - (const IntVector2& rhs) const;
  49. IntVector2 operator * (int rhs) const;
  50. IntVector2 operator * (const IntVector2& rhs) const;
  51. IntVector2 operator / (int rhs) const;
  52. IntVector2 operator / (const IntVector2& rhs) const;
  53. String ToString() const;
  54. unsigned ToHash() const;
  55. float Length() const;
  56. int x_ @ x;
  57. int y_ @ y;
  58. static const IntVector2 ZERO;
  59. static const IntVector2 LEFT;
  60. static const IntVector2 RIGHT;
  61. static const IntVector2 UP;
  62. static const IntVector2 DOWN;
  63. static const IntVector2 ONE;
  64. };
  65. Vector2 VectorLerp(const Vector2& lhs, const Vector2& rhs, const Vector2& t);
  66. Vector2 VectorMin(const Vector2& lhs, const Vector2& rhs);
  67. Vector2 VectorMax(const Vector2& lhs, const Vector2& rhs);
  68. Vector2 VectorFloor(const Vector2& vec);
  69. Vector2 VectorRound(const Vector2& vec);
  70. Vector2 VectorCeil(const Vector2& vec);
  71. IntVector2 VectorFloorToInt(const Vector2& vec);
  72. IntVector2 VectorRoundToInt(const Vector2& vec);
  73. IntVector2 VectorCeilToInt(const Vector2& vec);
  74. IntVector2 VectorMin(const IntVector2& lhs, const IntVector2& rhs);
  75. IntVector2 VectorMax(const IntVector2& lhs, const IntVector2& rhs);
  76. float StableRandom(const Vector2& seed);
  77. float StableRandom(float seed);