Engauge Digitizer  2
Spline.h
1 #include "SplineCoeff.h"
2 #include "SplinePair.h"
3 #include <vector>
4 
15 class Spline
16 {
17  public:
21  Spline(const std::vector<double> &t,
22  const std::vector<SplinePair> &xy);
23 
24  virtual ~Spline();
25 
29  int numIterations) const;
30 
33  SplinePair interpolateCoeff (double t) const;
34 
37  SplinePair interpolateControlPoints (double t) const;
38 
40  SplinePair p1 (unsigned int i) const;
41 
43  SplinePair p2 (unsigned int i) const;
44 
45 private:
46  Spline();
47 
48  // Although coefficient interpolation works for successive t values not 1.0 apart, the control point interpolation
49  // does not so we check the increments. Note that the starting value is arbitrary. Removing this restriction will
50  // mean upgrading the code to allow arbitrary t increments
51  void checkTIncrements (const std::vector<double> &t) const;
52 
53  void computeCoefficientsForIntervals (const std::vector<double> &t,
54  const std::vector<SplinePair> &xy);
55  void computeControlPointsForIntervals ();
56 
57  // Coefficients a,b,c,d
58  std::vector<SplineCoeff> m_elements;
59 
60  // Input times
61  std::vector<double> m_t;
62 
63  // Input points
64  std::vector<SplinePair> m_xy;
65 
66  // Control points for each interval
67  std::vector<SplinePair> m_p1;
68  std::vector<SplinePair> m_p2;
69 };
SplinePair interpolateCoeff(double t) const
Return interpolated y for specified x.
Definition: Spline.cpp:127
SplinePair interpolateControlPoints(double t) const
Return interpolated y for specified x, for testing.
Definition: Spline.cpp:140
Cubic interpolation given independent and dependent value vectors.
Definition: Spline.h:15
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].
Definition: Spline.cpp:162
SplinePair findSplinePairForFunctionX(double x, int numIterations) const
Use bisection algorithm to iteratively find the SplinePair interpolated to best match the specified x...
Definition: Spline.cpp:104
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].
Definition: Spline.cpp:169
Single X/Y pair for cubic spline interpolation initialization and calculations.
Definition: SplinePair.h:5