osu.Framework/MathUtils/Interpolation.cs
/// <summary>
/// Interpolates between a set of points using a lagrange polynomial.
/// </summary>
/// <param name="points">An array of coordinates. No two x should be the same.</param>
/// <param name="time">The x coordinate to calculate the y coordinate for.</param>
Interpolates between a set of points using a lagrange polynomial.
Interpolates between a set of points using a lagrange polynomial .
public static double Lagrange(ReadOnlySpan<Vector2> points, double time)
        {
            if (points == null || points.Length == 0)
                throw new ArgumentException($"{nameof(points)} must contain at least one point");
            double sum = 0;
            for (int i = 0; i < points.Length; i++)
                sum += points[i].Y * LagrangeBasis(points, i, time);
            return sum;
        }
public static double Lagrange ( ReadOnlySpan < Vector2 > points , double time ) { if ( points == null || points . Length == 0 ) throw new ArgumentException ( $" { nameof ( points ) }  must contain at least one point " ) ; double sum = 0 ; for ( int i = 0 ; i < points . Length ; i ++ ) sum += points [ i ] . Y * LagrangeBasis ( points , i , time ) ; return sum ; }
Interpolates between a set of points using a lagrange polynomial.
Interpolates between a set of points using a lagrange polynomial .
points
ReadOnlySpan<Vector2>
An array of coordinates. No two x should be the same.
An array of coordinates . No two x should be the same .
time
double
The x coordinate to calculate the y coordinate for.
The x coordinate to calculate the y coordinate for .