summaryrefslogtreecommitdiff
path: root/src/helpers/Vector2D.cpp
blob: acaace1390cc948a2e6a069497458d508e441722 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#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;
}

Vector2D Vector2D::floor() {
    return Vector2D((int)x, (int)y);
}