This repository has been archived on 2022-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
space-war/libmath.cpp

42 lines
827 B
C++

#include "libmath.hpp"
Point operator+(const Point& p1, const Point& p2) {
return Point{p1.x + p2.x, p1.y + p2.y};
}
Point operator-(const Point& p1, const Point& p2) {
return Point{p1.x - p2.x, p1.y - p2.y};
}
Point operator*(const Point& p1, const Point& p2) {
return Point{p1.x * p2.x, p1.y * p2.y};
}
Point operator/(const Point& p1, const Point& p2) {
return Point{p1.x / p2.x, p1.y / p2.y};
}
Point& operator+=(Point& p1, const Point& p2) {
p1.x += p2.x;
p1.y += p2.y;
return p1;
}
Point& operator-=(Point& p1, const Point& p2) {
p1.x -= p2.x;
p1.y -= p2.y;
return p1;
}
Point& operator*=(Point& p1, const Point& p2) {
p1.x *= p2.x;
p1.y *= p2.y;
return p1;
}
Point& operator/=(Point& p1, const Point& p2) {
p1.x /= p2.x;
p1.y /= p2.y;
return p1;
}