summaryrefslogtreecommitdiff
path: root/src/helpers/Vector2D.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-06-19 16:20:06 +0200
committerVaxry <vaxry@vaxry.net>2024-06-19 16:20:15 +0200
commitfb15b7aa2a9bba0f0693f84d0c65d386942583f8 (patch)
treed4403944b5d6a3e03d2262f03a7d0b3ed6ffae24 /src/helpers/Vector2D.cpp
parent6e5804b53de753f24953d9d647940df66bc68f6d (diff)
core: Move to hyprutils for Math
Moves CRegion, CBox and Vector2D over to hyprutils. Requires hyprutils>=0.1.4
Diffstat (limited to 'src/helpers/Vector2D.cpp')
-rw-r--r--src/helpers/Vector2D.cpp58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/helpers/Vector2D.cpp b/src/helpers/Vector2D.cpp
deleted file mode 100644
index 6f96d686..00000000
--- a/src/helpers/Vector2D.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "Vector2D.hpp"
-#include <algorithm>
-#include <cmath>
-
-Vector2D::Vector2D(double xx, double yy) {
- x = xx;
- y = yy;
-}
-
-Vector2D::Vector2D() {
- x = 0;
- y = 0;
-}
-
-Vector2D::Vector2D(const Hyprlang::VEC2& ref) {
- x = ref.x;
- y = ref.y;
-}
-
-Vector2D::~Vector2D() {}
-
-double Vector2D::normalize() {
- // get max abs
- const auto max = std::abs(x) > std::abs(y) ? std::abs(x) : std::abs(y);
-
- x /= max;
- y /= max;
-
- return max;
-}
-
-Vector2D Vector2D::floor() const {
- return Vector2D(std::floor(x), std::floor(y));
-}
-
-Vector2D Vector2D::round() const {
- return Vector2D(std::round(x), std::round(y));
-}
-
-Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) const {
- return Vector2D(std::clamp(this->x, min.x, max.x < min.x ? INFINITY : max.x), std::clamp(this->y, min.y, max.y < min.y ? INFINITY : max.y));
-}
-
-double Vector2D::distance(const Vector2D& other) const {
- return std::sqrt(distanceSq(other));
-}
-
-double Vector2D::distanceSq(const Vector2D& other) const {
- return (x - other.x) * (x - other.x) + (y - other.y) * (y - other.y);
-}
-
-double Vector2D::size() const {
- return std::sqrt(x * x + y * y);
-}
-
-Vector2D Vector2D::getComponentMax(const Vector2D& other) const {
- return Vector2D(std::max(this->x, other.x), std::max(this->y, other.y));
-}