Choreonoid  1.1
Interpolator.h
[詳解]
1 
6 #ifndef CNOID_UTIL_INTERPOLATOR_H_INCLUDED
7 #define CNOID_UTIL_INTERPOLATOR_H_INCLUDED
8 
9 #include <vector>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
15  {
16  public:
17  void clear();
18  int appendSample(double x, double y);
19  void setEndPoint(int sampleIndex, bool isNatural = false);
20  int numSamples();
21  bool update();
22  void getDomain(double& out_lower, double& out_upper);
23  double interpolate(double x);
24  //bool interpolate(double x, double& out_y, double& out_d2, double& out_d3);
25  //bool interpolate(double xBegin, double step, double* out_ybuf);
26  //bool interpolate(double xBegin, double step, double* out_ybuf, double* out_d2buf, double* out_d3buf);
27 
28  private:
29 
30  int updateCubicSplineSegment(int begin);
31  int updateSegmentBetweenTwoSamples(int begin);
32 
33  enum SegmentType { UNDETERMINED, CUBIC_SPLINE, POLYNOMINAL };
34 
35  struct Sample
36  {
37  double x;
38  double y;
39  double yp;
40 
41  // coefficients
42  double a;
43  double a_end;
44  double b;
45  double c;
46 
47  bool isEdge;
48  bool isNaturalEdge;
49  SegmentType segmentType;
50  };
51 
52  std::vector<Sample> samples;
53  int prevReferredSegments;
54  };
55 }
56 
57 #endif
Definition: Interpolator.h:14
#define CNOID_EXPORT
Definition: Util/exportdecl.h:13