Vector3.inl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * Vector3.inl
  3. */
  4. #include "Vector3.h"
  5. #include "Matrix.h"
  6. namespace gameplay
  7. {
  8. inline Vector3 Vector3::operator+(const Vector3& v)
  9. {
  10. Vector3 result(*this);
  11. result.add(v);
  12. return result;
  13. }
  14. inline Vector3& Vector3::operator+=(const Vector3& v)
  15. {
  16. add(v);
  17. return *this;
  18. }
  19. inline Vector3 Vector3::operator-(const Vector3& v)
  20. {
  21. Vector3 result(*this);
  22. result.subtract(v);
  23. return result;
  24. }
  25. inline Vector3& Vector3::operator-=(const Vector3& v)
  26. {
  27. subtract(v);
  28. return *this;
  29. }
  30. inline Vector3 Vector3::operator-()
  31. {
  32. Vector3 result(*this);
  33. result.negate();
  34. return result;
  35. }
  36. inline Vector3 Vector3::operator*(float x)
  37. {
  38. Vector3 result(*this);
  39. result.scale(x);
  40. return result;
  41. }
  42. inline Vector3& Vector3::operator*=(float x)
  43. {
  44. scale(x);
  45. return *this;
  46. }
  47. inline bool Vector3::operator<(const Vector3& v) const
  48. {
  49. if (x == v.x)
  50. {
  51. if (y == v.y)
  52. {
  53. return z < v.z;
  54. }
  55. return y < v.y;
  56. }
  57. return x < v.x;
  58. }
  59. inline bool Vector3::operator==(const Vector3& v) const
  60. {
  61. return x==v.x && y==v.y && z==v.z;
  62. }
  63. inline Vector3 operator*(float x, const Vector3& v)
  64. {
  65. Vector3 result(v);
  66. result.scale(x);
  67. return result;
  68. }
  69. }