Methods Summary |
---|
public static android.util.Spline | createLinearSpline(float[] x, float[] y)Creates a linear spline from a given set of control points.
Like a monotone cubic spline, the interpolated curve will be monotonic if the control points
are monotonic.
return new LinearSpline(x, y);
|
public static android.util.Spline | createMonotoneCubicSpline(float[] x, float[] y)Creates a monotone cubic spline from a given set of control points.
The spline is guaranteed to pass through each control point exactly.
Moreover, assuming the control points are monotonic (Y is non-decreasing or
non-increasing) then the interpolated values will also be monotonic.
This function uses the Fritsch-Carlson method for computing the spline parameters.
http://en.wikipedia.org/wiki/Monotone_cubic_interpolation
return new MonotoneCubicSpline(x, y);
|
public static android.util.Spline | createSpline(float[] x, float[] y)Creates an appropriate spline based on the properties of the control points.
If the control points are monotonic then the resulting spline will preserve that and
otherwise optimize for error bounds.
if (!isStrictlyIncreasing(x)) {
throw new IllegalArgumentException("The control points must all have strictly "
+ "increasing X values.");
}
if (isMonotonic(y)) {
return createMonotoneCubicSpline(x, y);
} else {
return createLinearSpline(x, y);
}
|
public abstract float | interpolate(float x)Interpolates the value of Y = f(X) for given X.
Clamps X to the domain of the spline.
|
private static boolean | isMonotonic(float[] x)
if (x == null || x.length < 2) {
throw new IllegalArgumentException("There must be at least two control points.");
}
float prev = x[0];
for (int i = 1; i < x.length; i++) {
float curr = x[i];
if (curr < prev) {
return false;
}
prev = curr;
}
return true;
|
private static boolean | isStrictlyIncreasing(float[] x)
if (x == null || x.length < 2) {
throw new IllegalArgumentException("There must be at least two control points.");
}
float prev = x[0];
for (int i = 1; i < x.length; i++) {
float curr = x[i];
if (curr <= prev) {
return false;
}
prev = curr;
}
return true;
|