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.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/helpers/Vector2D.cpp (limited to 'src/helpers/Vector2D.cpp') 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 -- cgit v1.2.3