Hyprland/src/helpers/Vector2D.cpp

23 lines
382 B
C++
Raw Normal View History

2022-03-16 22:21:12 +01:00
#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;
2022-03-17 15:53:45 +01:00
}
Vector2D Vector2D::floor() {
return Vector2D((int)x, (int)y);
2022-03-16 22:21:12 +01:00
}