LibGfx: Templatize VectorN::length()

This allows us to get a `float` length from an `IntVector3` without
needing to convert to `FloatVector3` first.
This commit is contained in:
Jelle Raaijmakers 2022-09-10 14:17:24 +02:00 committed by Linus Groh
parent 70ea2a2258
commit 16ca9ec762
Notes: sideshowbarker 2024-07-17 07:15:08 +09:00

View File

@ -205,9 +205,10 @@ public:
operator*=(inv_length);
}
[[nodiscard]] constexpr T length() const
template<typename O = T>
[[nodiscard]] constexpr O length() const
{
return AK::sqrt(dot(*this));
return AK::sqrt<O>(dot(*this));
}
[[nodiscard]] constexpr VectorN<2, T> xy() const requires(N >= 3)