BiasCorrectQ.Program.Interpolate C# (CSharp) Method

Interpolate() private static method

private static Interpolate ( double value, List valuesList, List interpList ) : double
value double
valuesList List
interpList List
return double
        private static double Interpolate(double value, List<double> valuesList,
            List<double> interpList)
        {
            int idx = Utils.ValueIndex(value, valuesList);

            // out of bounds, interpolation unknown
            if (idx < 0)
            {
            return idx;
            }

            // no interpolation needed, first value in list
            if (idx == 0)
            {
            return interpList.First();
            }

            double x = value;
            double x1 = valuesList[idx - 1];
            double x2 = valuesList[idx];

            double y1 = interpList[idx - 1];
            double y2 = interpList[idx];

            return Utils.Interpolate(x, x1, x2, y1, y2);
        }