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.

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