BALL  1.4.1
cubicSpline1D.h
Go to the documentation of this file.
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       
00052       CubicSpline1D(const std::vector<float>& sample_positions, 
00053                     const std::vector<float>& sample_values, 
00054                     bool return_average = false, 
00055                     bool is_natural = true, 
00056                     float lower_derivative = 0.0,
00057                     float upper_derivative = 0.0,
00058                     int verbosity = VERBOSITY_LEVEL_DEBUG);
00059     
00072       CubicSpline1D(const std::vector<float>& sample_positions, 
00073                     const std::vector<float>& sample_values, 
00074                     float default_value,
00075                     bool is_natural = true, 
00076                     float lower_derivative = 0.0,
00077                     float upper_derivative = 0.0,
00078                     int verbosity = VERBOSITY_LEVEL_DEBUG);
00079     
00092       CubicSpline1D(const std::vector<float>& sample_positions, 
00093                     const std::vector<float>& sample_values, 
00094                     float default_value, 
00095                     float lower_bound, 
00096                     float upper_bound,  
00097                     bool is_natural = true, 
00098                     float lower_derivative = 0.0,
00099                     float upper_derivative = 0.0,
00100                     int verbosity = VERBOSITY_LEVEL_DEBUG);
00101       
00114       CubicSpline1D(const std::vector<float>& sample_positions, 
00115                     const std::vector<float>& sample_values, 
00116                     float lower_bound, 
00117                     float upper_bound,  
00118                     bool return_average = false,
00119                     float default_value = std::numeric_limits<float>::min(), 
00120                     bool is_natural = true, 
00121                     float lower_derivative = 0.0,
00122                     float upper_derivative = 0.0,
00123                     int verbosity = VERBOSITY_LEVEL_DEBUG);
00124 
00125 
00128       CubicSpline1D(const CubicSpline1D& cs1D);
00129       
00132       virtual ~CubicSpline1D();
00133   
00135       void setVerbosity(int verbosity) { verbosity_ = verbosity; }
00136 
00138       int  getVerbosity() const { return verbosity_; }
00139       
00147       float operator () (float x);
00148 
00151       std::vector<float> getCurvature() const {return curvature_;}
00152       
00159       void setCurvature(std::vector<float> curvature);
00160       
00165       void setValues(std::vector<float> values, bool recompute = true);
00166       
00169       std::vector<float> getValues() const {return sample_values_;}
00170       
00173       std::vector<float> getPositions() const {return sample_positions_;}
00174       
00179       void setPositions(std::vector<float> positions, bool recompute = true);
00180       
00183       void  setDefaultValue(float value) {default_value_ = value;}
00184       float getDefaultValue() const {return default_value_;}              
00185 
00190       void setLowerBound(float lb) {lower_bound_ = lb;}
00191       void setUpperBound(float ub) {upper_bound_ = ub;}
00192 
00195       float getLowerBound() const {return lower_bound_;}
00196       float getUpperBound() const {return upper_bound_;}
00197     
00199       bool isNatural() const {return  is_natural_;}
00200       
00204       void makeNatural(bool recompute = true);
00205       
00210       void setBoudaryDerivatives(float lower_derivative, float upper_derivative, bool recompute = true);
00211       
00217       void setLowerDerivative(float derivative, bool recompute = true);
00218       
00220       float getLowerDerivative() const {return lower_derivative_;}
00221       
00227       void setUpperDerivative(float derivative, bool recompute = true);
00228       
00230       float getUpperDerivative() const  {return upper_derivative_;}
00231 
00232     private : 
00233       
00239       void createSpline(); 
00240     
00241       // Sample positions of the spline.
00242       std::vector<float> sample_positions_;
00243       // Sample values of the spline.
00244       std::vector<float> sample_values_;
00245       // Curvature of the spline.
00246       std::vector<float> curvature_;
00247       
00248       // Flag to denote, if the default values should be set to the average 
00249       bool return_average_;
00250       
00255       float default_value_; 
00256       
00257       // Lower bound of the spline
00258       float lower_bound_;
00259 
00260       // Upper bound of the spline
00261       float upper_bound_;
00262       
00263       // Flag to denote, if the spline is natural 
00264       bool is_natural_;
00265       
00266       // Value of the first derivative of the lower sample position
00267       float lower_derivative_;
00268       
00269       // Value of the first derivative of the upper sample position
00270       float upper_derivative_;
00271 
00273       int verbosity_;
00274   };
00275 
00276 }
00277 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines