aboutsummaryrefslogtreecommitdiff
path: root/XY.cpp
blob: e2aa0754d5a730845a0044db59a5f417d7b69377 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "XY.h"

XY XY::operator - () const {
	return XY {
		.x = -x,
		.y = -y,
	};
}

XY XY::operator + (const XY & rhs) const {
	return XY {
		.x = x + rhs.x,
		.y = y + rhs.y,
	};
}

XY XY::operator - (const XY & rhs) const {
	return XY {
		.x = x - rhs.x,
		.y = y - rhs.y,
	};
}

XY& XY::operator += (const XY & rhs) {
	this->x += rhs.x;
	this->y += rhs.y;
	return *this;
}

XY& XY::operator -= (const XY & rhs) {
	this->x -= rhs.x;
	this->y -= rhs.y;
	return *this;
}

bool XY::operator == (const XY& rhs) const {
	if (this->x != rhs.x) return false;
	if (this->y != rhs.y) return false;
	return true;
}

bool XY::operator != (const XY& rhs) const {
	return !(*this == rhs);
}