diff --git a/src/helpers/Vector2D.hpp b/src/helpers/Vector2D.hpp index c79c967c..34b06862 100644 --- a/src/helpers/Vector2D.hpp +++ b/src/helpers/Vector2D.hpp @@ -25,10 +25,10 @@ class Vector2D { Vector2D operator-() const { return Vector2D(-this->x, -this->y); } - Vector2D operator*(const float& a) const { + Vector2D operator*(const double& a) const { return Vector2D(this->x * a, this->y * a); } - Vector2D operator/(const float& a) const { + Vector2D operator/(const double& a) const { return Vector2D(this->x / a, this->y / a); } @@ -55,6 +55,36 @@ class Vector2D { bool operator<(const Vector2D& a) const { return this->x < a.x && this->y < a.y; } + Vector2D& operator+=(const Vector2D& a) { + this->x += a.x; + this->y += a.y; + return *this; + } + Vector2D& operator-=(const Vector2D& a) { + this->x -= a.x; + this->y -= a.y; + return *this; + } + Vector2D& operator*=(const Vector2D& a) { + this->x *= a.x; + this->y *= a.y; + return *this; + } + Vector2D& operator/=(const Vector2D& a) { + this->x /= a.x; + this->y /= a.y; + return *this; + } + Vector2D& operator*=(const double& a) { + this->x *= a; + this->y *= a; + return *this; + } + Vector2D& operator/=(const double& a) { + this->x /= a; + this->y /= a; + return *this; + } double distance(const Vector2D& other) const; double size() const;