You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vector2d.cpp 898B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "vector2d.h"
  2. Vector2D::Vector2D(double x, double y)
  3. : VectorXD<2>()
  4. {
  5. _scalars[0] = x;
  6. _scalars[1] = y;
  7. }
  8. Vector2D::Vector2D(const Vector2D &other)
  9. : VectorXD<2>(other)
  10. {
  11. }
  12. Vector2D::Vector2D(const VectorXD<2> &other)
  13. : VectorXD<2>(other)
  14. {
  15. }
  16. Vector2D::~Vector2D()
  17. {
  18. }
  19. double Vector2D::getX() const
  20. {
  21. return _scalars[0];
  22. }
  23. Vector2D& Vector2D::setX(double x)
  24. {
  25. _scalars[0] = x;
  26. return *this;
  27. }
  28. double Vector2D::getY() const
  29. {
  30. return _scalars[1];
  31. }
  32. Vector2D& Vector2D::setY(double y)
  33. {
  34. _scalars[1] = y;
  35. return *this;
  36. }
  37. Vector2D &Vector2D::add(double x, double y)
  38. {
  39. _scalars[0] += x;
  40. _scalars[1] += y;
  41. return *this;
  42. }
  43. Vector2D &Vector2D::sub(double x, double y)
  44. {
  45. _scalars[0] -= x;
  46. _scalars[1] -= y;
  47. return *this;
  48. }
  49. double Vector2D::dotProduct(double x, double y) const
  50. {
  51. return dotProduct(Vector2D(x, y));
  52. }