summaryrefslogtreecommitdiff
path: root/src/helpers/Vector2D.hpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-16 22:21:12 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-16 22:21:12 +0100
commit52090853dafb75dd99969a0cecdd291c109210f8 (patch)
tree282fa613a51e24366512723517278ff9f444edb1 /src/helpers/Vector2D.hpp
parentffd309ca2adc313f2aaaea08b4cac9553982b48c (diff)
added vector2d
Diffstat (limited to 'src/helpers/Vector2D.hpp')
-rw-r--r--src/helpers/Vector2D.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/helpers/Vector2D.hpp b/src/helpers/Vector2D.hpp
new file mode 100644
index 00000000..9bc427e8
--- /dev/null
+++ b/src/helpers/Vector2D.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <math.h>
+
+class Vector2D {
+ public:
+ Vector2D(double, double);
+ Vector2D();
+ ~Vector2D();
+
+ double x = 0;
+ double y = 0;
+
+ // returns the scale
+ double normalize();
+
+ Vector2D operator+(Vector2D a) {
+ return Vector2D(this->x + a.x, this->y + a.y);
+ }
+ Vector2D operator-(Vector2D a) {
+ return Vector2D(this->x - a.x, this->y - a.y);
+ }
+ Vector2D operator*(float a) {
+ return Vector2D(this->x * a, this->y * a);
+ }
+ Vector2D operator/(float a) {
+ return Vector2D(this->x / a, this->y / a);
+ }
+}; \ No newline at end of file