Vector.cpp 651 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "Vector.h"
  2. Vec3f::Vec3f(float x, float y, float z)
  3. {
  4. this->x = x;
  5. this->y = y;
  6. this->z = z;
  7. }
  8. Vec3f::Vec3f()
  9. {
  10. this->x = 0;
  11. this->y = 0;
  12. this->z = 0;
  13. }
  14. Vec3f::Vec3f(Vec3f &other)
  15. {
  16. this->x = other.x;
  17. this->y = other.y;
  18. this->z = other.z;
  19. }
  20. float& Vec3f::operator [](int index)
  21. {
  22. return v[index];
  23. }
  24. Vec2f::Vec2f(float x, float y)
  25. {
  26. this->x = x;
  27. this->y = y;
  28. }
  29. Vec2f::Vec2f()
  30. {
  31. this->x = 0;
  32. this->y = 0;
  33. }
  34. Vec2f::Vec2f(Vec2f &other)
  35. {
  36. this->x = other.x;
  37. this->y = other.y;
  38. }
  39. float& Vec2f::operator [](int index)
  40. {
  41. return v[index];
  42. }
  43. Vec2f Vec2f::operator+(const Vec2f & other)
  44. {
  45. return Vec2f(x + other.x, y+other.y);
  46. }