public class Spline extends FunctionCurve
Create a Spline Curve, or more accurately a sequence of spline curves
which can be used to interpolate or approximate, or just plain "Smooth"
a DataCurve
.
Currently this class provides two predefined spline curves which can be mapped to a collection of data points.
A CatmullRom spline is a spline curve which passes through every
point on the DataCurve
, guaranteed.
A BSpline is a spline curve which approximates the data
points it's based on. A BSpline may not pass through any of the points
supplied, but will tend to lessen the influence of "spikes" in the data.
BSplines conventionally use the first and last points as control points
only. This class generates useful values for the first and last points
on the DataCurve
by repeating the first and last values
in the data set.
The curves are defined by the basis matrix for the spline. If the basis matrix has less rows than the number of points in the datacurve, several curves are "patched" together, using the n points of the datacurve starting at point 0, then point 1, then point 2 and so on.
If you haven't understood a word of this, you failed calculus at school, but you still still want your curves to be nice and smooth, just use a CatmullRom spline like this:
DataCurve data = new DataCurve(); data.add(x,y); // Add data to the curve . . Curve smooth = new Spline(Spline.CATMULLROM, data);
Modifier and Type  Field and Description 

static Matrix 
BSPLINE
Defines the basis matrix for a Bspline

static Matrix 
CATMULLROM
Defines the basis matrix for a CatmullRom spline

Constructor and Description 

Spline(Matrix matrix,
DataCurve d)
Return a new Spline curve of the specified type fitted to the
supplied
DataCurve . 
Spline(Matrix matrix,
double[] x,
double[] y)
Return a new Spline curve of the specified type fitted to the
array of X and Y values supplied.

Modifier and Type  Method and Description 

double 
get(double x)
Return the value of the spline at the specified X value.

double 
getMax()
Return the maximum value that is defined for this curve.

double 
getMin()
Return the minimum value that is defined for this curve.

boolean 
point(double x)
If a marker is to be placed at this point on the curve then return
true, otherwise return false.

double[] 
steps()
Return the points on the curve that it should be sampled at to get an
accurate picture of it.

public static final Matrix CATMULLROM
public static final Matrix BSPLINE
public Spline(Matrix matrix, DataCurve d)
DataCurve
.matrix
 The basis matrix for the curve. May be
CATMULLROM
, BSPLINE
or a userdefined 4x4 matrix.d
 the datacurve to fit to.public Spline(Matrix matrix, double[] x, double[] y)
matrix
 The basis matrix for the curve. May be
CATMULLROM
, BSPLINE
or a userdefined matrix.x
 the X values to fit the curve toy
 the Y values to fit the curve topublic double get(double x)
public double getMin()
Curve
Double.POSITIVE_INFINITY
(yes, positive)getMin
in class FunctionCurve
public double getMax()
Curve
Double.NEGATIVE_INFINITY
(yes, negative)getMax
in class FunctionCurve
public double[] steps()
Curve
FunctionCurve
may return
an empty list if they wish, or if there are certain points that the
curve must be sampled at, it can return them here.steps
in class FunctionCurve
public boolean point(double x)
Curve
FunctionCurve
will return
false, but curves that have been fitted to a DataCurve
may
return any points from that DataCurve
that are matched
exactly by the fitted curve.point
in class FunctionCurve
Copyright © 20012018 Big Faceless Organization