Package adams.data

Class InterpolationUtils


  • public class InterpolationUtils
    extends Object
    Helper class for interpolation.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double interpolate​(double x, double xLeft, double yLeft, double xRight, double yRight)
      Interpolates the Y value for a given X and the surrounding x/y pairs.
      static double interpolate​(double x, double xLeft, double yLeft, double xRight, double yRight, double[] weights)
      Interpolates the Y value for a given X and the surrounding x/y pairs.
      static double[] weights​(double x, double xLeft, double xRight)
      Calculates the interpolation weights for the left and right X.
    • Constructor Detail

      • InterpolationUtils

        public InterpolationUtils()
    • Method Detail

      • weights

        public static double[] weights​(double x,
                                       double xLeft,
                                       double xRight)
        Calculates the interpolation weights for the left and right X.
        Parameters:
        x - the X to calculate the interpolation weights
        xLeft - the X to the left
        xRight - the X to the right
        Returns:
        the weights (left=0, right=1)
      • interpolate

        public static double interpolate​(double x,
                                         double xLeft,
                                         double yLeft,
                                         double xRight,
                                         double yRight,
                                         double[] weights)
        Interpolates the Y value for a given X and the surrounding x/y pairs.
        Parameters:
        x - the X to generate the interpolated Y for
        xLeft - the X to the left
        yLeft - the Y to the left
        xRight - the X to the right
        yRight - the Y to the right
        weights - array of length 2 to store the weights in (left/right)
        Returns:
        the interpolated Y
      • interpolate

        public static double interpolate​(double x,
                                         double xLeft,
                                         double yLeft,
                                         double xRight,
                                         double yRight)
        Interpolates the Y value for a given X and the surrounding x/y pairs.
        Parameters:
        x - the X to generate the interpolated Y for
        xLeft - the X to the left
        yLeft - the Y to the left
        xRight - the X to the right
        yRight - the Y to the right
        Returns:
        the interpolated Y