My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
QuadraticInterpolator.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_QUADRATICINTERPOLATOR_H
2 #define GCP_UTIL_QUADRATICINTERPOLATOR_H
3 
11 #include <pthread.h>
12 #include <iostream>
13 
18 #define QP_ANGLE_FN(fn) double (fn)(double angle)
19 
20 namespace gcp {
21  namespace util {
22 
49 
50  public:
51 
55  static const double pi_;
56  static const double twopi_;
57 
62  enum QuadType {
63 
68 
73 
78  };
79 
80  //------------------------------------------------------------
81  // Public methods
82  //------------------------------------------------------------
83 
87  virtual ~QuadraticInterpolator();
88 
99  void empty();
100 
135  void extend(double x, double y);
136 
140  double evaluate(double x);
141 
145  double gradient(double x);
146 
150  void lock();
151 
155  void unlock();
156 
161  bool tryLock();
162 
167  bool canBracket(double x);
168 
173  unsigned getNpt();
174 
179  double getXmin();
180 
185  double getXmax();
186 
187  protected:
188 
193 
204 
209  void setEmptyValue(double emptyValue);
210 
211  friend std::ostream& gcp::util::operator<<(std::ostream& os, QuadraticInterpolator& quad);
212 
213  private:
214 
215  //------------------------------------------------------------
216  // Resources for locking this container
217  //------------------------------------------------------------
218 
222  bool mutexIsReady_;
223 
227  pthread_mutex_t mutex_;
228 
229  //------------------------------------------------------------
230  // Structs used by this class.
231  //------------------------------------------------------------
232 
236  struct QuadSample {
237  double x;
238  double y;
239  };
240 
245  struct QuadData {
246 
261  int npt;
262 
266  QuadSample s[3];
267 
271  void init();
272  };
273 
274  //------------------------------------------------------------
275  // Private data members
276  //------------------------------------------------------------
277 
278  double emptyValue_; // The value to use when npt==0
279  double x0_; // A value which will be subtracted off
280  // of the x-value to maintain accuracy
281  double a_,b_,c_; // The coefficients of the quadratic
282  // equation that interpolates x[],y[]
283  QuadSample s_[3]; // The samples to interpolate between
284  int npt_; // The number of values in x[] and y[]
285 
286  //------------------------------------------------------------
287  // Private methods
288  //------------------------------------------------------------
289 
299  virtual double fixAngle(double angle);
300 
306  void get(QuadData* data);
307 
326  void set(QuadData* data);
327 
332  double extendAngle(double a, double b);
333 
334  }; // End class QuadraticInterpolator
335 
336  } // End namespace util
337 } // End namespace gcp
338 
339 
340 #endif
double getXmax()
Definition: QuadraticInterpolator.cc:620
Definition: QuadraticInterpolator.h:77
bool canBracket(double x)
Definition: QuadraticInterpolator.cc:581
Definition: QuadraticInterpolator.h:48
void setEmptyValue(double emptyValue)
Definition: QuadraticInterpolator.cc:60
Definition: QuadraticInterpolator.h:67
void lock()
Definition: QuadraticInterpolator.cc:527
bool tryLock()
Definition: QuadraticInterpolator.cc:559
double getXmin()
Definition: QuadraticInterpolator.cc:611
void extend(double x, double y)
Definition: QuadraticInterpolator.cc:165
Definition: QuadraticInterpolator.h:72
unsigned getNpt()
Definition: QuadraticInterpolator.cc:602
static const double pi_
Definition: QuadraticInterpolator.h:55
void empty()
Definition: QuadraticInterpolator.cc:75
void unlock()
Definition: QuadraticInterpolator.cc:545
double evaluate(double x)
Definition: QuadraticInterpolator.cc:102
virtual ~QuadraticInterpolator()
Definition: QuadraticInterpolator.cc:48
QuadraticInterpolator()
Definition: QuadraticInterpolator.cc:26
QuadType
Definition: QuadraticInterpolator.h:62
QuadType type_
Definition: QuadraticInterpolator.h:192
double gradient(double x)
Definition: QuadraticInterpolator.cc:124