Initial commit

This commit is contained in:
2023-05-06 18:33:58 +02:00
commit c9500a5548
18 changed files with 790 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
#pragma once
template <typename T>
class Vec2
{
public:
Vec2() = default;
constexpr Vec2(T x, T y)
:
x(x),
y(y)
{}
constexpr T GetX() const {return x;};
constexpr T GetY() const {return y;};
constexpr void SetX(T x_in) { x = x_in;};
constexpr void SetY(T y_in) { y = y_in;};
public:
constexpr bool operator==(const Vec2& rhs) const
{
return (x == rhs.x && y == rhs.y);
}
constexpr bool operator!=(const Vec2& rhs) const
{
return !(*this == rhs);
}
constexpr Vec2 operator+(const Vec2& rhs) const
{
return {x + rhs.x, y + rhs.y};
}
constexpr Vec2 operator+(const int rhs) const
{
return {x + rhs, y + rhs};
}
constexpr Vec2& operator+=(const Vec2& rhs)
{
return *this = *this + rhs;
}
constexpr Vec2 operator-(const Vec2& rhs) const
{
return {x - rhs.x, y - rhs.y};
}
constexpr Vec2 operator-(const int rhs) const
{
return { x - rhs, y - rhs};
}
constexpr Vec2& operator-=(const Vec2& rhs)
{
return *this = *this - rhs;
}
constexpr Vec2 operator*(const Vec2& rhs) const
{
return {x * rhs.x, y * rhs.y};
}
constexpr Vec2 operator*(const int rhs) const
{
return { x * rhs, y * rhs };
}
constexpr Vec2& operator*=(const Vec2& rhs)
{
return *this = *this * rhs;
}
private:
T x;
T y;
};