Package com.flarerobotics.lib.math
Class BilinearInterpolator2D
java.lang.Object
com.flarerobotics.lib.math.BilinearInterpolator2D
A generic 2D bilinear interpolator over an axis-aligned grid. Takes in a matrix input, and
outputs a double corresponding to the interpolated result.
-
Constructor Summary
ConstructorsConstructorDescriptionBilinearInterpolator2D
(double[] X, double[] Y, double[][] V) Constructs a new BilinearInterpolator2D. -
Method Summary
Modifier and TypeMethodDescriptiondouble
interpolate
(double x, double y) Perform bilinear interpolation at (x, y).
-
Constructor Details
-
BilinearInterpolator2D
public BilinearInterpolator2D(double[] X, double[] Y, double[][] V) Constructs a new BilinearInterpolator2D.(Row i -> X[i], Col j -> Y[j])
- Parameters:
X
- Sorted X-axis grid of length MY
- Sorted Y-axis grid of length NV
- MxN matrix of values: V[i][j] = f(X[i], Y[j])
-
-
Method Details
-
interpolate
public double interpolate(double x, double y) Perform bilinear interpolation at (x, y).- If x or y is outside grid boundaries, extrapolates using nearest segment
- Parameters:
x
- The X coordinate.y
- The Y coordinate.- Returns:
- The interpolated value at (x, y).
-