Hyprland/src/helpers/Vector2D.hpp

39 lines
809 B
C++
Raw Normal View History

2022-03-16 22:21:12 +01:00
#pragma once
#include <math.h>
class Vector2D {
public:
Vector2D(double, double);
Vector2D();
~Vector2D();
double x = 0;
double y = 0;
// returns the scale
double normalize();
2022-03-18 22:35:51 +01:00
Vector2D operator+(const Vector2D a) {
2022-03-16 22:21:12 +01:00
return Vector2D(this->x + a.x, this->y + a.y);
}
2022-03-18 22:35:51 +01:00
Vector2D operator-(const Vector2D a) {
2022-03-16 22:21:12 +01:00
return Vector2D(this->x - a.x, this->y - a.y);
}
2022-03-18 22:35:51 +01:00
Vector2D operator*(const float a) {
2022-03-16 22:21:12 +01:00
return Vector2D(this->x * a, this->y * a);
}
2022-03-18 22:35:51 +01:00
Vector2D operator/(const float a) {
2022-03-16 22:21:12 +01:00
return Vector2D(this->x / a, this->y / a);
}
2022-03-17 15:53:45 +01:00
2022-03-18 22:35:51 +01:00
bool operator==(const Vector2D& a) {
2022-03-17 15:53:45 +01:00
return a.x == x && a.y == y;
}
2022-03-18 22:35:51 +01:00
bool operator!=(const Vector2D& a) {
2022-03-17 15:53:45 +01:00
return a.x != x || a.y != y;
}
Vector2D floor();
2022-03-16 22:21:12 +01:00
};