aboutsummaryrefslogtreecommitdiff
path: root/XY.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-23 19:16:19 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-23 19:16:19 +0200
commit1e0a52b03fe655d7073ef20703dbb2e7646f74d3 (patch)
treef1709c2e9565d78c791653e71e6a4b26b3138423 /XY.cpp
parent277157b3e06b2deeacbdbc8bf6190de19f88169d (diff)
add XY struct for 2d points and offsets
Diffstat (limited to 'XY.cpp')
-rw-r--r--XY.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/XY.cpp b/XY.cpp
new file mode 100644
index 0000000..ad1262b
--- /dev/null
+++ b/XY.cpp
@@ -0,0 +1,35 @@
+#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;
+}
+