public abstract class Interpolator extends Object
Making some assumptions, interpolation is fairly straightforward. Most of the methods implemented here are designed to support interpolation (or derivation) of y-values keyed to monotonically increasing x-values. x-value interpolation is somewhat thornier. Assumptions and behaviors:
Presently, only single value interpolation of x-values is supported. The more common use case is to resample a sequence of y-values, which is supported.
Two static methods, findX(double, double, double, double, double)
and findY(double, double, double, double, double), are the basis for
all interpolation operations in this class. These two methods are point-order
agnostic.
TODO example; explain array swapping techniques for x-interpolation
| Modifier and Type | Class and Description |
|---|---|
static class |
Interpolator.Builder |
| Modifier and Type | Method and Description |
|---|---|
static Interpolator.Builder |
builder() |
abstract double |
findX(double[] xs,
double[] ys,
double y)
Return an interpolated x-value corresponding to the supplied y-value in the
supplied x- and y-value arrays.
|
static double |
findX(double x1,
double y1,
double x2,
double y2,
double y)
Return an interpolated or extrapolated x-value corresponding to the
supplied y-value.
|
abstract double |
findX(List<Double> xs,
List<Double> ys,
double y)
Return an interpolated x-value corresponding to the supplied y-value in the
supplied x- and y-value arrays.
|
abstract double |
findX(XySequence xys,
double y)
Return an interpolated x-value corresponding to the supplied y-value in the
supplied xy-sequence.
|
abstract double |
findY(double[] xs,
double[] ys,
double x)
Return an interpolated or extrapolated y-value corresponding to the
supplied x-value in the supplied x- and y-value arrays.
|
abstract double[] |
findY(double[] xs,
double[] ys,
double[] x)
Return interpolated or extrapolated y-values using the supplied x- and
y-value arrays.
|
static double |
findY(double x1,
double y1,
double x2,
double y2,
double x)
Return an interpolated or extrapolated y-value corresponding to the
supplied x-value.
|
abstract double |
findY(List<Double> xs,
List<Double> ys,
double x)
Return an interpolated or extrapolated y-value corresponding to the
supplied x-value in the supplied x- and y-value arrays.
|
abstract double[] |
findY(List<Double> xs,
List<Double> ys,
double[] x)
Return interpolated or extrapolated y-values using the supplied x- and
y-value arrays.
|
abstract double |
findY(XySequence xys,
double x)
Return an interpolated or extrapolated y-value corresponding to the
supplied x-value in the supplied xy-sequence.
|
abstract double[] |
findY(XySequence xys,
double[] x)
Return interpolated or extrapolated y-values using the supplied x- and
y-value arrays.
|
public static double findX(double x1,
double y1,
double x2,
double y2,
double y)
NaN, returned value will
also be NaN. Method does not perform any input validation such that
if the supplied points are coincident or define a horizontal line, the
method may return Infinity, -Infinity, or NaN.x1 - x-value of first pointy1 - y-value of first pointx2 - x-value of second pointy2 - y-value of second pointy - value at which to find xpublic abstract double findX(double[] xs,
double[] ys,
double y)
xs - x-values of a sequenceys - y-values of a sequencey - value at which to find xpublic abstract double findX(List<Double> xs, List<Double> ys, double y)
xs - x-values of a sequenceys - y-values of a sequencey - value at which to find xpublic abstract double findX(XySequence xys, double y)
xys - an xy-sequencey - value at which to find xpublic static double findY(double x1,
double y1,
double x2,
double y2,
double x)
NaN, returned value will
also be NaN. Method does not perform any input validation such that
if the supplied points are coincident or define a vertical line, the method
may return Infinity, -Infinity, or NaN.x1 - x-value of first pointy1 - y-value of first pointx2 - x-value of second pointy2 - y-value of second pointx - value at which to find ypublic abstract double findY(double[] xs,
double[] ys,
double x)
xs - x-values of a sequenceys - y-values of a sequencex - value at which to find ypublic abstract double findY(List<Double> xs, List<Double> ys, double x)
xs - x-values of a sequenceys - y-values of a sequencex - value at which to find ypublic abstract double findY(XySequence xys, double x)
xys - an xy-sequencex - value at which to find ypublic abstract double[] findY(double[] xs,
double[] ys,
double[] x)
xs - x-values of a sequenceys - y-values of a sequencex - values at which to find y-valuespublic abstract double[] findY(List<Double> xs, List<Double> ys, double[] x)
xs - x-values of a sequenceys - y-values of a sequencex - values at which to find y-valuespublic abstract double[] findY(XySequence xys, double[] x)
xys - an xy-sequencex - values at which to find y-valuespublic static Interpolator.Builder builder()