Package ca.spatial.patchworks
Class Curve
java.lang.Object
ca.spatial.patchworks.Curve
This class implements linear interpolated curves that are represented
by a series of points. The class is instantiated with arrays of x
and y floating point values. The
getY(float)
method will retrieve
an estimate of the Y value for any given X value.
Linear interpolation is used for calculating values of Y where the X value lies between two points. When the X value is lower than the lowest X value in the curve, then the lowest Y value is returned. When the X value is higher than the highest X value in the curve, then the highest Y value is returned.
A curve containing a single point will return a constant value for any value of X.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Curve
public Curve(float[] xp, float[] yp)Construct a curve from a series of points. All points in the input arrays will be used. This constructor is equivalent tonew Curve(xp, yp, xp.length);
- Parameters:
xp
- An array of x-values that represent the series of points in the curveyp
- An array of y-values that represent the series of points in the curve
-
Curve
public Curve(float[] xp, float[] yp, int n)Construct a curve from a series of points. The constructor will automatically discard unnecessary points.The X values must be in monotonically increasing order.
- Parameters:
xp
- An array of x-values that represent the series of points in the curveyp
- An array of y-values that represent the series of points in the curven
- The number of points that are in the arrays. Points in the array beyond 'n' will be ignored.
-
-
Method Details