Math: Remove Algorithm file and move string functions to StringExt

This commit is contained in:
SirLynix
2023-06-06 08:59:58 +02:00
parent c87c45f332
commit caf8446707
31 changed files with 132 additions and 425 deletions

View File

@@ -619,6 +619,12 @@ namespace Nz
return lhs.ApproxEqual(rhs, maxDifference);
}
template<AngleUnit Unit, typename T>
constexpr Angle<Unit, T> Angle<Unit, T>::Clamp(Angle angle, Angle min, Angle max)
{
return Angle(std::clamp(angle.value, min.value, max.value));
}
/*!
* \brief Builds an Angle instance using a FromUnit angle, converting if needed
* \return An angle describing the FromUnit angle as Unit
@@ -720,6 +726,21 @@ namespace Nz
return Detail::AngleUtils<Unit>::ToString(out, angle.value);
}
/*!
* \ingroup math
* \brief Clamps an angle value between min and max and returns the expected value
* \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval
*
* \param value Value to clamp
* \param min Minimum of the interval
* \param max Maximum of the interval
*/
template<typename T, AngleUnit Unit>
constexpr Angle<Unit, T> Clamp(Angle<Unit, T> value, T min, T max)
{
return std::max(std::min(value.value, max), min);
}
/*!
* \brief Serializes an Angle
* \return true if successfully serialized