summaryrefslogtreecommitdiff
path: root/src/helpers/Vector2D.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/Vector2D.cpp')
-rw-r--r--src/helpers/Vector2D.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/helpers/Vector2D.cpp b/src/helpers/Vector2D.cpp
new file mode 100644
index 00000000..33b12e7c
--- /dev/null
+++ b/src/helpers/Vector2D.cpp
@@ -0,0 +1,19 @@
+#include "Vector2D.hpp"
+
+Vector2D::Vector2D(double xx, double yy) {
+ x = xx;
+ y = yy;
+}
+
+Vector2D::Vector2D() { x = 0; y = 0; }
+Vector2D::~Vector2D() {}
+
+double Vector2D::normalize() {
+ // get max abs
+ const auto max = abs(x) > abs(y) ? abs(x) : abs(y);
+
+ x /= max;
+ y /= max;
+
+ return max;
+} \ No newline at end of file