mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-05 11:25:59 +01:00
98a4fa2b0d
* clang-format stuff and format files
32 lines
No EOL
623 B
C++
32 lines
No EOL
623 B
C++
#include "Vector2D.hpp"
|
|
#include <algorithm>
|
|
|
|
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);
|
|
}
|
|
|
|
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
|
|
return Vector2D(std::clamp(this->x, min.x, max.x == 0 ? INFINITY : max.x), std::clamp(this->y, min.y, max.y == 0 ? INFINITY : max.y));
|
|
} |