From 52090853dafb75dd99969a0cecdd291c109210f8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 16 Mar 2022 22:21:12 +0100 Subject: added vector2d --- src/helpers/Vector2D.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/helpers/Vector2D.hpp (limited to 'src/helpers/Vector2D.hpp') 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 + +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 -- cgit v1.2.3