// // Created by saintruler on 05.05.19. // #include "Point.h" Point::Point(double x, double y) { this->x = x; this->y = y; } Point operator+(const Point& left, const Point& right) { return Point(left.x + right.x, left.y + right.y); } Point operator+=(Point& left, const Point& right) { left.x += right.x; left.y += right.y; return left; } Point operator-(const Point& left, const Point& right) { return Point(left.x - right.x, left.y - right.y); } Point operator-=(Point& left, const double right) { left.x -= right; left.y -= right; return left; } Point operator/(const Point& left, const double right) { return Point(left.x / right, left.y / right); } Point operator/=(Point& left, const double right) { left.x /= right; left.y /= right; return left; } Point operator*(const Point& left, const double right) { return Point(left.x * right, left.y * right); } Point operator*=(Point& left, const double right) { left.x *= right; left.y *= right; return left; } double Point::length() { return sqrt(pow(x, 2) + pow(y, 2)); } double Point::length_squared() { return pow(x, 2) + pow(y, 2); } void Point::normalize() { const double l = length(); this->x /= l; this->y /= l; }