00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _GOSPLINEINTERPOLATOR_H
00034 #define _GOSPLINEINTERPOLATOR_H
00035
00036
00037 #include "Interpolator.h"
00038 #include "BsplineBasis.h"
00039 #include "Point.h"
00040 #include <boost/smart_ptr.hpp>
00041
00042
00043 namespace Go
00044 {
00047
00048
00052 class SplineInterpolator : public Interpolator
00053 {
00054 public:
00056 SplineInterpolator()
00057 : ctype_(None), basis_set_(false)
00058 {
00059 }
00060
00062 virtual ~SplineInterpolator();
00063
00064
00065 virtual const BsplineBasis& basis();
00066
00089 void interpolate(const std::vector<double>& params,
00090 const std::vector<double>& points,
00091 const std::vector<int>& tangent_index,
00092 const std::vector<double>& tangent_points,
00093 int order,
00094 std::vector<double>& coefs);
00095
00103 void interpolate(const std::vector<double>& params,
00104 const std::vector<double>& points,
00105 const std::vector<int>& tangent_index,
00106 const std::vector<double>& tangent_points,
00107 std::vector<double>& coefs);
00108
00116 virtual void interpolate(int num_points, int dimension,
00117 const double* param_start,
00118 const double* data_start,
00119 std::vector<double>& coefs);
00120
00137 enum CondType { None, Hermite, Natural, Free, NaturalAtStart, NaturalAtEnd };
00138
00144 void setHermiteConditions(const Point& start_tangent,
00145 const Point& end_tangent) {
00146 ctype_ = Hermite;
00147 start_tangent_ = boost::shared_ptr<Point>(new Point(start_tangent));
00148 end_tangent_ = boost::shared_ptr<Point>(new Point(end_tangent));
00149 }
00150
00154 void setNaturalConditions() { ctype_ = Natural; }
00155
00161 void setNaturalStartCondition() { ctype_ = NaturalAtStart;}
00162
00168 void setNaturalEndCondition() { ctype_ = NaturalAtEnd; }
00169
00173 void setFreeConditions() { ctype_ = Free; }
00174
00180 void setEndTangents(boost::shared_ptr<Point>& start_tangent,
00181 boost::shared_ptr<Point>& end_tangent)
00182 {
00183 start_tangent_ = start_tangent;
00184 end_tangent_ = end_tangent;
00185 if (start_tangent.get() != 0 && end_tangent.get() != 0)
00186 ctype_ = Hermite;
00187 else if (start_tangent.get() != 0)
00188 ctype_ = NaturalAtEnd;
00189 else if (end_tangent.get() != 0)
00190 ctype_ = NaturalAtStart;
00191 else
00192 ctype_ = Natural;
00193 }
00194
00197 CondType getCondType() {return ctype_; }
00198
00206 void makeBasis(const std::vector<double>& params,
00207 const std::vector<int>& tangent_index,
00208 int order);
00209
00212
00217 void setBasis(BsplineBasis& basis) {
00218 basis_ = basis;
00219 basis_set_ = true;
00220 }
00221
00222 private:
00223 CondType ctype_;
00224 boost::shared_ptr<Point> start_tangent_;
00225 boost::shared_ptr<Point> end_tangent_;
00226 BsplineBasis basis_;
00227 bool basis_set_;
00228 };
00229
00230
00231
00233 }
00234
00235
00236 #endif // _GOSPLINEINTERPOLATOR_H
00237
00238