Class BilinearInterpolator2D

java.lang.Object
com.flarerobotics.lib.math.BilinearInterpolator2D

public class BilinearInterpolator2D extends Object
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 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 M
      Y - Sorted Y-axis grid of length N
      V - 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).