Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/math/spline.h @ 10510

Last change on this file since 10510 was 10368, checked in by patrick, 18 years ago

merged the branche playability into the trunk

File size: 2.8 KB
Line 
1
2#ifndef __Spline_h
3#define __Spline_h
4
5#include "vtkObject.h"
6
7class Spline
8{
9public:
10
11  // Description:
12  // Set/Get the parametric range. If not set, the range is determined
13  // implicitly by keeping track of the (min,max) parameter values for
14  // t. If set, the AddPoint() method will clamp the t value to lie
15  // within the specified range.
16  void SetParametricRange(double tMin, double tMax);
17  void SetParametricRange(double tRange[2])
18    {this->SetParametricRange(tRange[0],tRange[1]);}
19  void GetParametricRange(double tRange[2]) const;
20
21
22  // Description:
23  // Compute the coefficients for the spline.
24  virtual void Compute () = 0;
25
26  // Description:
27  // Interpolate the value of the spline at parametric location of t.
28  virtual double Evaluate (double t) = 0;
29
30  // Description:
31  // Return the number of points inserted thus far.
32  int GetNumberOfPoints();
33
34  // Description:
35  // Add a pair of points to be fit with the spline.
36  void AddPoint (double t, double x);
37
38  // Description:
39  // Remove a point from the data to be fit with the spline.
40  void RemovePoint (double t);
41
42  // Description:
43  // Remove all points from the data.
44  void RemoveAllPoints ();
45
46
47
48protected:
49  Spline();
50  ~Spline();
51
52  unsigned long ComputeTime;
53  // Description:
54  // Set/Get ClampValue. If On, results of the interpolation will be
55  // clamped to the min/max of the input data.
56  int ClampValue;
57  double *Intervals;
58  double *Coefficients;
59  int LeftConstraint;
60  // Description:
61  // The values of the derivative on the left and right sides. The value
62  // is used only if the left(right) constraint is type 1-3.
63  double LeftValue;
64  // Description:
65  // Set the type of constraint of the left(right) end points. Four
66  // constraints are available:
67  //
68  // 0: the first derivative at left(right) most point is determined
69  // from the line defined from the first(last) two points.
70  //
71  // 1: the first derivative at left(right) most point is set to
72  // Left(Right)Value.
73  //
74  // 2: the second derivative at left(right) most point is set to
75  // Left(Right)Value.
76  //
77  // 3: the second derivative at left(right)most points is Left(Right)Value
78  // times second derivative at first interior point.
79  int RightConstraint;
80  double RightValue;
81  vtkPiecewiseFunction *PiecewiseFunction;
82  // Description:
83  // Control whether the spline is open or closed. A closed spline forms
84  // a continuous loop: the first and last points are the same, and
85  // derivatives are continuous.
86
87  int Closed;
88
89  // Explicitly specify the parametric range.
90  double ParametricRange[2];
91
92  // Helper methods
93  double ComputeLeftDerivative();
94  double ComputeRightDerivative();
95  int FindIndex(int size, double t);
96
97private:
98  Spline(const Spline&);  // Not implemented.
99  void operator=(const Spline&);  // Not implemented.
100};
101
102#endif
Note: See TracBrowser for help on using the repository browser.