Vector4.inl 1.5 KB

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