Gin
Loading...
Searching...
No Matches
Functions
Lagrange Namespace Reference

Lagrange interpolation functions for obtaining smooth curves from discrete points. More...

Functions

template<typename T >
interpolate (const juce::Array< Point< T > > &points, T x)
 Interpolates a value at coordinate x using Lagrange polynomial interpolation.
 
template<typename T >
interpolate (T xArr[], T yArr[], int num, T x)
 Interpolates a value at coordinate x using Lagrange polynomial interpolation.
 

Detailed Description

Lagrange interpolation functions for obtaining smooth curves from discrete points.

Lagrange interpolation creates a polynomial that passes through all given points. Unlike splines, it uses a single polynomial rather than piecewise functions. Note that for large numbers of points, the resulting polynomial can oscillate significantly (Runge's phenomenon).

See also
interpolate

Function Documentation

◆ interpolate() [1/2]

template<typename T >
T Lagrange::interpolate ( const juce::Array< Point< T > > &  points,
x 
)

Interpolates a value at coordinate x using Lagrange polynomial interpolation.

Creates a polynomial that passes through all the given points and evaluates it at the specified x coordinate. The resulting polynomial has degree n-1 where n is the number of points.

Parameters
pointsAn array of Point<T> defining the interpolation curve
xThe x coordinate at which to evaluate the interpolated value
Returns
The interpolated y value at coordinate x

Referenced by DelayLine::readLagrange(), and DelayLine::readSampleLagrange().

◆ interpolate() [2/2]

template<typename T >
T Lagrange::interpolate ( xArr[],
yArr[],
int  num,
x 
)

Interpolates a value at coordinate x using Lagrange polynomial interpolation.

This overload accepts separate arrays for x and y coordinates rather than an array of points. Creates a polynomial that passes through all the given points and evaluates it at the specified x coordinate.

Parameters
xArrArray of x coordinates
yArrArray of y coordinates (must be same length as xArr)
numNumber of points in the arrays
xThe x coordinate at which to evaluate the interpolated value
Returns
The interpolated y value at coordinate x