Java Array Interpolate interpolate(double[] array, int[] translation, double index)

Here you can find the source of interpolate(double[] array, int[] translation, double index)

Description

interpolate

License

Open Source License

Declaration

public static double interpolate(double[] array, int[] translation, double index) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double interpolate(double[] array, int[] translation, double index) {
        int length = translation == null ? array.length : translation.length;
        int floor = (int) index;
        int[] intIndex = new int[] { floor % length, (floor + 1) % length };
        if (translation != null)
            for (int i = 0; i < intIndex.length; i++)
                intIndex[i] = translation[intIndex[i]];
        double[] value = new double[] { array[intIndex[0]], array[intIndex[1]] };
        double percent = index - floor;
        return value[0] + percent * (value[1] - value[0]);
    }/*from   w  w w  .j a  va2 s.c om*/

    public static double interpolate(double[] array, double index) {
        return interpolate(array, null, index);
    }
}

Related

  1. interpolate(double x, double xLeft, double yLeft, double xRight, double yRight, double[] weights)
  2. interpolate(double x, double[] begin, double[] end)
  3. interpolate(double xa[], double ya[], double x)
  4. interpolate(double[] end0, double[] end1, double[] mid)
  5. interpolate(double[] points, double[] values, double interpolateAt)
  6. interpolate(double[] x, double D)
  7. interpolate(double[] X, double[] Y, double[] Z)