spline_unit_test
 All Classes Functions Enumerations
raven::cSpline Class Reference

#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
 

Detailed Description

A 2D cubic spline : draws a set of smooth curves through points

Constructor & Destructor Documentation

raven::cSpline::cSpline ( std::vector< double > &  x,
std::vector< double > &  y 
)

Constructor: Calculates the spline curve coefficients

Parameters
[in]xThe x points
[in]yThe y points

The x points must be in increasing order, with a minimum delta of 1.0

Member Function Documentation

void raven::cSpline::Draw ( std::function< void(double x, double y)>  func,
int  resolution = 100 
)

Draw the spline curves

Parameters
[in]thedrawing function
[in]resolutionThe 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

Parameters
[in]x
Returns
the y value
e_error raven::cSpline::IsError ( )
inline

Check for error

Returns
0 if all OK, otherwise an error number
bool raven::cSpline::IsSane ( )
inline

Check if input is insane

Returns
true if all OK

The documentation for this class was generated from the following files: