Inheritance diagram for DzNaturalSpline:
Methods | |
void | clear () |
void | deletePoint (Number index) |
Number | getMax () |
Number | getMin () |
Number | getNumPoints () |
Number | getValue (Number x) |
Number | getX (Number index) |
Number | getY (Number index) |
void | insertPoint (Number x, Number y) |
void | setX (Number index, Number x) |
void | setY (Number index, Number y) |
Constructors | |
DzNaturalSpline () | |
Signals | |
void | splineChanged () |
Signature: "splineChanged()" |
This class encapsulates the behavior of a standard natural spline. A natural spline is a special case of a cubic spline that has zero second derivative at its two end boundaries. A standard reference for natural splines are the Numerical Recipes books that can be found online.
The spline can be initially constructed either by setting a default curve or by inserting two or more points.
The spline value y at a point x is found with the function getValue(). The y extrema of the curve can be found via getMinMax().
The spline point x,y coordinates should be limited to the range 0<=x<= 1 and 0<=y<=1 for proper functioning and this is explicitly enforced by the set functions.
The resulting spline curve may extend above or below those ranges.
DzNaturalSpline::DzNaturalSpline | ( | ) |
Default Constructor.
void DzNaturalSpline::clear | ( | ) |
Removes all spline data. Number of points is set to zero.
void DzNaturalSpline::deletePoint | ( | Number | index | ) |
Deletes the spline point at the designated index.
index | The zero based index of the point to be deleted. |
double DzNaturalSpline::getMax | ( | ) |
double DzNaturalSpline::getMin | ( | ) |
int DzNaturalSpline::getNumPoints | ( | ) |
Gets the number of points the spline has. Used with getX(i) and getX(i) to loop over the spline points.
Computes the y value on the spline for the given x. If the passed x is out of the range, then the y value for the closest endpoint is returned.
x | The x coordinate. |
Gets the x value of the point at position index in the point array.
index | The zero based index of the point. |
Gets the y value of the point at position index in the point array.
index | The zero based index of the point. |
Inserts a new point in the spline at position x, y. If there is allready a point in the spline with the same x value, then its y coordinate is replaced with new value.
x | The x value of the point. | |
y | The y value of the point. |
Sets the x value of the point at position index in the point array.
index | The zero based index of the point. | |
x | The x value of the point. |
Sets the y value of the point at position index in the point array.
index | The zero based index of the point. | |
y | The y value of the point. |
void DzNaturalSpline::splineChanged | ( | ) | [signal] |
Signature: "splineChanged()"
Emitted when the values of the spline have changed.