|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph.math.Curve
org.faceless.graph.math.FunctionCurve
org.faceless.graph.math.Spline
public class Spline
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 pre-defined spline curves which can be mapped to a collection of data points.
A Catmull-Rom spline is a spline curve which passes through every
point on the DataCurve
, guaranteed.
A B-Spline is a spline curve which approximates the data
points it's based on. A B-Spline may not pass through any of the points
supplied, but will tend to lessen the influence of "spikes" in the data.
B-Splines 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 Catmull-Rom spline like this:
DataCurve data = new DataCurve(); data.add(x,y); // Add data to the curve . . Curve smooth = new Spline(Spline.CATMULLROM, data);
Matrix
,
DataCurve
Field Summary | |
---|---|
static Matrix |
BSPLINE
Defines the basis matrix for a B-spline |
static Matrix |
CATMULLROM
Defines the basis matrix for a Catmull-Rom spline |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Matrix CATMULLROM
public static final Matrix BSPLINE
Constructor Detail |
---|
public Spline(Matrix matrix, DataCurve d)
DataCurve
.
matrix
- The basis matrix for the curve. May be
CATMULLROM
, BSPLINE
or a user-defined 4x4 matrix.d
- the data-curve to fit to.public Spline(Matrix matrix, double[] x, double[] y)
matrix
- The basis matrix for the curve. May be
CATMULLROM
, BSPLINE
or a user-defined matrix.x
- the X values to fit the curve toy
- the Y values to fit the curve toMethod Detail |
---|
public double get(double x)
get
in class Curve
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |