light/modules/math/include/math/vec2.hpp
light7734 f9ce347ca0
feat: initial math module implementation
refactor: replace glm with built-in math library
2025-07-17 10:44:00 +03:30

56 lines
756 B
C++

#pragma once
namespace lt::math {
template<typename T = float>
struct vec2_impl
{
vec2_impl(): x(), y()
{
}
explicit vec2_impl(T scalar): x(scalar), y(scalar)
{
}
vec2_impl(T x, T y): x(x), y(y)
{
}
[[nodiscard]] auto operator*(const vec2_impl<T> &other) const -> vec2_impl
{
return {
x * other.x,
y * other.y,
};
}
[[nodiscard]] auto operator-(const vec2_impl<T> &other) const -> vec2_impl
{
return {
x - other.x,
y - other.y,
};
}
[[nodiscard]] auto operator*(float scalar) const -> vec2_impl
{
return {
x * scalar,
y * scalar,
};
}
T x; // NOLINT
T y; // NOLINT
};
using vec2 = vec2_impl<float>;
using ivec2 = vec2_impl<int32_t>;
using uvec2 = vec2_impl<uint32_t>;
} // namespace lt::math