diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-03-16 22:21:12 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-03-16 22:21:12 +0100 |
| commit | 52090853dafb75dd99969a0cecdd291c109210f8 (patch) | |
| tree | 282fa613a51e24366512723517278ff9f444edb1 /src/helpers/Vector2D.cpp | |
| parent | ffd309ca2adc313f2aaaea08b4cac9553982b48c (diff) | |
added vector2d
Diffstat (limited to 'src/helpers/Vector2D.cpp')
| -rw-r--r-- | src/helpers/Vector2D.cpp | 19 |
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 |
