|
spline_unit_test
|
#include <cSpline.h>
Public Types | |
| enum | e_error { no_error, x_not_ascending, no_input, not_single_valued } |
| error numbers | |
Public Member Functions | |
| cSpline (std::vector< double > &x, std::vector< double > &y) | |
| bool | IsSane () |
| e_error | IsError () |
| void | Draw (std::function< void(double x, double y)> func, int resolution=100) |
| double | getY (double x) |
Public Attributes | |
| enum raven::cSpline::e_error | myError |
A 2D cubic spline : draws a set of smooth curves through points
| raven::cSpline::cSpline | ( | std::vector< double > & | x, |
| std::vector< double > & | y | ||
| ) |
Constructor: Calculates the spline curve coefficients
| [in] | x | The x points |
| [in] | y | The y points |
The x points must be in increasing order, with a minimum delta of 1.0
| void raven::cSpline::Draw | ( | std::function< void(double x, double y)> | func, |
| int | resolution = 100 |
||
| ) |
Draw the spline curves
| [in] | the | drawing function |
| [in] | resolution | The number of times to call the drawing function, default 100. |
This method will iterate between the minimum and maximum x values calling the drawing function 100 times with evenly spaced values of x and the y value of the spline curve for that x.
Example of usage
double xold = x0;
double yold = spline.getY( x0 );
spline.Draw( [&] ( double x, double y )
{
dc.DrawLine( xold, yold, x, y );
xold = x;
yold = y;
});
| double raven::cSpline::getY | ( | double | x | ) |
Get the Y value of the spline curves for a particular X
| [in] | x |
|
inline |
Check for error
|
inline |
Check if input is insane