feat: Math.Lerp

This commit is contained in:
Syntriax 2024-10-20 14:47:42 +03:00
parent f08f721f52
commit eca23c5b89
1 changed files with 10 additions and 0 deletions

View File

@ -157,6 +157,16 @@ public static class Math
/// <returns>The number <paramref name="x"/> raised to the power <paramref name="y"/>.</returns>
public static float Pow(float x, float y) => MathF.Pow(x, y);
/// <summary>
/// Performs linear interpolation between two specified values.
/// </summary>
/// <typeparam name="T">The type of the values, which must implement <see cref="IFloatingPoint{T}"/>.</typeparam>
/// <param name="x">The starting value of the interpolation.</param>
/// <param name="y">The ending value of the interpolation.</param>
/// <param name="t">The interpolation factor, typically in the range [0, 1].</param>
/// <returns>A value that represents the linear interpolation between <paramref name="x"/> and <paramref name="y"/>.</returns>
public static T Lerp<T>(T x, T y, T t) where T : IFloatingPoint<T> => x + (y - x) * t;
/// <summary>
/// Rounds a number to a specified number of fractional digits.
/// </summary>