00001 #ifndef BALL_MATHS_CUBICSPLINE1D_H
00002 #define BALL_MATHS_CUBICSPLINE1D_H
00003
00004 #include <set>
00005 #include <map>
00006
00007 #ifndef BALL_COMMON_H
00008 # include <BALL/common.h>
00009 #endif
00010
00011 #ifndef BALL_COMMON_LIMITS_H
00012 # include <BALL/COMMON/limits.h>
00013 #endif
00014
00015 #ifndef BALL_DATATYPE_OPTIONS_H
00016 # include <BALL/DATATYPE/options.h>
00017 #endif
00018
00019 namespace BALL
00020 {
00021
00022 class BALL_EXPORT CubicSpline1D
00023 {
00024 public:
00025
00026 static const int VERBOSITY_LEVEL_DEBUG;
00027 static const int VERBOSITY_LEVEL_CRITICAL;
00028
00032
00033 BALL_CREATE(CubicSpline1D)
00034
00035
00036
00038 CubicSpline1D()
00039 throw();
00040
00053 CubicSpline1D(const std::vector<float>& sample_positions,
00054 const std::vector<float>& sample_values,
00055 bool return_average = false,
00056 bool is_natural = true,
00057 float lower_derivative = 0.0,
00058 float upper_derivative = 0.0,
00059 int verbosity = VERBOSITY_LEVEL_DEBUG)
00060 throw();
00061
00074 CubicSpline1D(const std::vector<float>& sample_positions,
00075 const std::vector<float>& sample_values,
00076 float default_value,
00077 bool is_natural = true,
00078 float lower_derivative = 0.0,
00079 float upper_derivative = 0.0,
00080 int verbosity = VERBOSITY_LEVEL_DEBUG)
00081 throw();
00082
00095 CubicSpline1D(const std::vector<float>& sample_positions,
00096 const std::vector<float>& sample_values,
00097 float default_value,
00098 float lower_bound,
00099 float upper_bound,
00100 bool is_natural = true,
00101 float lower_derivative = 0.0,
00102 float upper_derivative = 0.0,
00103 int verbosity = VERBOSITY_LEVEL_DEBUG)
00104 throw();
00105
00118 CubicSpline1D(const std::vector<float>& sample_positions,
00119 const std::vector<float>& sample_values,
00120 float lower_bound,
00121 float upper_bound,
00122 bool return_average = false,
00123 float default_value = std::numeric_limits<float>::min(),
00124 bool is_natural = true,
00125 float lower_derivative = 0.0,
00126 float upper_derivative = 0.0,
00127 int verbosity = VERBOSITY_LEVEL_DEBUG)
00128 throw();
00129
00130
00133 CubicSpline1D(const CubicSpline1D& cs1D)
00134 throw();
00135
00138 virtual ~CubicSpline1D()
00139 throw();
00140
00142 void setVerbosity(int verbosity) { verbosity_ = verbosity; }
00143
00145 int getVerbosity() const { return verbosity_; }
00146
00154 float operator () (float x) throw();
00155
00158 std::vector<float> getCurvature() const
00159 throw() {return curvature_;}
00160
00167 void setCurvature(std::vector<float> curvature) throw();
00168
00173 void setValues(std::vector<float> values, bool recompute = true) throw();
00174
00177 std::vector<float> getValues() const throw() {return sample_values_;}
00178
00181 std::vector<float> getPositions() const throw() {return sample_positions_;}
00182
00187 void setPositions(std::vector<float> positions, bool recompute = true) throw();
00188
00191 void setDefaultValue(float value) throw() {default_value_ = value;}
00192 float getDefaultValue() const throw() {return default_value_;}
00193
00198 void setLowerBound(float lb) throw() {lower_bound_ = lb;}
00199 void setUpperBound(float ub) throw() {upper_bound_ = ub;}
00200
00203 float getLowerBound() const throw() {return lower_bound_;}
00204 float getUpperBound() const throw() {return upper_bound_;}
00205
00207 bool isNatural() const throw() {return is_natural_;}
00208
00212 void makeNatural(bool recompute = true) throw();
00213
00218 void setBoudaryDerivatives(float lower_derivative, float upper_derivative, bool recompute = true) throw();
00219
00225 void setLowerDerivative(float derivative, bool recompute = true) throw();
00226
00228 float getLowerDerivative() const throw() {return lower_derivative_;}
00229
00235 void setUpperDerivative(float derivative, bool recompute = true) throw();
00236
00238 float getUpperDerivative() const throw() {return upper_derivative_;}
00239
00240 private :
00241
00247 void createSpline()
00248 throw();
00249
00250
00251
00252 std::vector<float> sample_positions_;
00253
00254 std::vector<float> sample_values_;
00255
00256 std::vector<float> curvature_;
00257
00258
00259 bool return_average_;
00260
00265 float default_value_;
00266
00267
00268 float lower_bound_;
00269
00270
00271 float upper_bound_;
00272
00273
00274 bool is_natural_;
00275
00276
00277 float lower_derivative_;
00278
00279
00280 float upper_derivative_;
00281
00283 int verbosity_;
00284 };
00285
00286 }
00287 #endif