fixed some stuff added constexpr

This commit is contained in:
2024-10-20 00:25:03 +03:00
parent c45bca2e0b
commit ef24377049
8 changed files with 37 additions and 70 deletions

View File

@@ -114,7 +114,10 @@ namespace omath
return x * vOther.x + y * vOther.y;
}
[[nodiscard]] float Length() const;
[[nodiscard]] constexpr float Length() const
{
return std::hypot(x, y);
}
[[nodiscard]] constexpr float LengthSqr() const
{
@@ -167,7 +170,11 @@ namespace omath
}
// Normalize the vector
[[nodiscard]] Vector2 Normalized() const;
[[nodiscard]] constexpr Vector2 Normalized() const
{
const float len = Length();
return len > 0.f ? *this / len : *this;
}
// Sum of elements
[[nodiscard]] constexpr float Sum() const