Engauge Digitizer
2
|
Cubic interpolation given independent and dependent value vectors. More...
#include <Spline.h>
Public Member Functions | |
Spline (const std::vector< double > &t, const std::vector< SplinePair > &xy) | |
Initialize spline with independent (t) and dependent (x and y) value vectors. More... | |
SplinePair | findSplinePairForFunctionX (double x, int numIterations) const |
Use bisection algorithm to iteratively find the SplinePair interpolated to best match the specified x value. More... | |
SplinePair | interpolateCoeff (double t) const |
Return interpolated y for specified x. More... | |
SplinePair | interpolateControlPoints (double t) const |
Return interpolated y for specified x, for testing. More... | |
SplinePair | p1 (unsigned int i) const |
Bezier p1 control point for specified interval. P0 is m_xy[i] and P3 is m_xy[i+1]. | |
SplinePair | p2 (unsigned int i) const |
Bezier p2 control point for specified interval. P0 is m_xy[i] and P3 is m_xy[i+1]. | |
Cubic interpolation given independent and dependent value vectors.
X is handled as a dependent variable based on the unitless independent parameter t so curves are not restricted to x(i)!=x(i+1).
This class has two modes that can be run side by side:
Spline::Spline | ( | const std::vector< double > & | t, |
const std::vector< SplinePair > & | xy | ||
) |
Initialize spline with independent (t) and dependent (x and y) value vectors.
Besides initializing the a,b,c,d coefficients for each interval, this constructor initializes bezier points (P1 and P2) for each interval, where P0 and P3 are the start and end points for each interval.
Definition at line 11 of file Spline.cpp.
SplinePair Spline::findSplinePairForFunctionX | ( | double | x, |
int | numIterations | ||
) | const |
Use bisection algorithm to iteratively find the SplinePair interpolated to best match the specified x value.
This assumes the curve is a function since otherwise there is the potential for multiple solutions
Definition at line 116 of file Spline.cpp.
SplinePair Spline::interpolateCoeff | ( | double | t | ) | const |
Return interpolated y for specified x.
The appropriate interval is selected from the entire set of piecewise-defined intervals, then the corresponding a,b,c,d coefficients are applied
Definition at line 166 of file Spline.cpp.
SplinePair Spline::interpolateControlPoints | ( | double | t | ) | const |
Return interpolated y for specified x, for testing.
This uses the bezier points. If the t values are not separated by +1 consistently then this algorithm will probably need additional effort to work right
Definition at line 179 of file Spline.cpp.