Vector.cpp 855 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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(const 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. Vec3f Vec3f::operator+(const Vec3f & other)
  25. {
  26. return Vec3f(x + other.x, y + other.y, z + other.z);
  27. }
  28. Vec3f Vec3f::operator/(float value)
  29. {
  30. return Vec3f(x / value, y / value, z / value);
  31. }
  32. Vec2f::Vec2f(float x, float y)
  33. {
  34. this->x = x;
  35. this->y = y;
  36. }
  37. Vec2f::Vec2f()
  38. {
  39. this->x = 0;
  40. this->y = 0;
  41. }
  42. Vec2f::Vec2f(const Vec2f &other)
  43. {
  44. this->x = other.x;
  45. this->y = other.y;
  46. }
  47. float& Vec2f::operator [](int index)
  48. {
  49. return v[index];
  50. }
  51. Vec2f Vec2f::operator+(const Vec2f & other)
  52. {
  53. return Vec2f(x + other.x, y+other.y);
  54. }