00001 #ifndef BALL_MATHS_CUBICSPLINE2D_H
00002 #define BALL_MATHS_CUBICSPLINE2D_H
00003
00004 #include <set>
00005 #include <map>
00006
00007 #ifndef BALL_MATHS_CUBICSPLINE1D_H
00008 # include <BALL/MATHS/cubicSpline1D.h>
00009 #endif
00010
00011 #ifndef BALL_COMMON_EXCEPTION_H
00012 #include <BALL/COMMON/exception.h>
00013 #endif
00014
00015 namespace BALL
00016 {
00017 class BALL_EXPORT CubicSpline2D
00018 {
00019 public:
00020
00021 static const int VERBOSITY_LEVEL_DEBUG;
00022 static const int VERBOSITY_LEVEL_CRITICAL;
00023
00024 BALL_CREATE(CubicSpline2D)
00025
00026
00030
00033 CubicSpline2D()
00034 throw();
00035
00036
00053 CubicSpline2D(const std::vector<std::vector<float> >& sample_positions_x,
00054 const std::vector<float>& sample_positions_y,
00055 const std::vector<std::vector<float> >& sample_values,
00056 bool return_average = false,
00057 bool is_natural = true,
00058 const std::vector<float>& x_lower_derivatives = std::vector<float>(),
00059 const std::vector<float>& x_upper_derivatives = std::vector<float>(),
00060 float y_lower_derivative = 0.,
00061 float y_upper_derivative = 0.,
00062 int verbosity = VERBOSITY_LEVEL_DEBUG)
00063 throw();
00064
00065
00066
00083 CubicSpline2D(const std::vector<std::vector<float> >& sample_positions_x,
00084 const std::vector<float>& sample_positions_y,
00085 const std::vector<std::vector<float> >& sample_values,
00086 const std::vector<float>& x_default_values,
00087 float y_default_value,
00088 const std::vector<float>& x_lower_bounds,
00089 const std::vector<float>& x_upper_bounds,
00090 float y_lower_bound,
00091 float y_upper_bound,
00092 bool is_natural = true,
00093 const std::vector<float>& x_lower_derivatives = std::vector<float>(),
00094 const std::vector<float>& x_upper_derivatives = std::vector<float>(),
00095 float y_lower_derivative = 0.0,
00096 float y_upper_derivative = 0.0,
00097 int verbosity = VERBOSITY_LEVEL_DEBUG)
00098 throw();
00099
00100
00101
00102
00103
00120 CubicSpline2D(const std::vector<float>& sample_positions_x,
00121 const std::vector<float>& sample_positions_y,
00122 const std::vector<std::vector<float> >& sample_values,
00123 bool return_average = false,
00124 bool is_natural = true,
00125 const std::vector<float>& x_lower_derivatives = std::vector<float>(),
00126 const std::vector<float>& x_upper_derivatives = std::vector<float>(),
00127 float y_lower_derivative = 0.,
00128 float y_upper_derivative = 0.,
00129 int verbosity = VERBOSITY_LEVEL_DEBUG)
00130 throw();
00131
00148 CubicSpline2D(const std::vector<float>& sample_positions_x,
00149 const std::vector<float>& sample_positions_y,
00150 const std::vector<std::vector<float> >& sample_values,
00151 const std::vector<float>& x_default_values,
00152 float y_default_value,
00153 const std::vector<float>& x_lower_bounds,
00154 const std::vector<float>& x_upper_bounds,
00155 float y_lower_bound,
00156 float y_upper_bound,
00157 bool is_natural = true,
00158 const std::vector<float>& x_lower_derivatives = std::vector<float>(),
00159 const std::vector<float>& x_upper_derivatives = std::vector<float>(),
00160 float y_lower_derivative = 0.0,
00161 float y_upper_derivative = 0.0,
00162 int verbosity = VERBOSITY_LEVEL_DEBUG)
00163 throw();
00164
00165
00168 CubicSpline2D(const CubicSpline2D& cs2D)
00169 throw();
00170
00173 virtual ~CubicSpline2D()
00174 throw();
00175
00177 void setVerbosity(int verbosity);
00178
00189 float operator () (float x, float y)
00190 throw();
00191
00192
00193
00194 float getXDefaultValue(Index x) const throw(Exception::OutOfRange);
00195
00196
00197 float getYDefaultValue() const throw () {return y_default_value_;}
00198
00199 void setXDefaultValues(vector<float> x_default_values) throw() {x_default_values_ = x_default_values;}
00200
00201 void setYDefaultValue(float y_default_value) throw() {y_default_value_ = y_default_value;}
00202
00203
00204
00205 void setYLowerBound(float lb) throw() {y_lower_bound_ = lb;}
00206 void setYUpperBound(float ub) throw() {y_upper_bound_ = ub;}
00207
00208 float getYLowerBound() throw() {return y_lower_bound_;}
00209 float getYUpperBound() throw() {return y_upper_bound_;}
00210
00211 void setXLowerBounds(vector<float> lb) throw() {x_lower_bounds_ = lb;}
00212 void setXUpperBounds(vector<float> ub) throw() {x_upper_bounds_ = ub;}
00214 const vector<float>& getXLowerBounds() const throw(Exception::OutOfRange) {return x_lower_bounds_ ;}
00215 const vector<float>& getXUpperBounds() const throw(Exception::OutOfRange) {return x_upper_bounds_;}
00218 float getXLowerBounds(Index x) const throw(Exception::OutOfRange);
00219 float getXUpperBounds(Index x) const throw(Exception::OutOfRange);
00220
00221
00224 bool isXNatural(Index x) throw();
00225 vector<bool> isXNatural() const throw() {return x_is_natural_;}
00229 void makeXNatural(Index x, bool recompute = true) throw();
00233 void makeAllXNatural(bool recompute = true) throw();
00238 void makeYNatural(bool y_is_natural, bool recompute = true) throw();
00239
00240
00241 bool isYNatural() throw() {return y_is_natural_;}
00242
00243
00244 void setXLowerDerivatives(vector<float> ld, bool recompute = true) throw();
00245 void setXUpperDerivatives(vector<float> ud, bool recompute = true) throw();
00249 float getXLowerDerivatives(Index x) throw(Exception::OutOfRange);
00250 float getXUpperDerivatives(Index x) throw(Exception::OutOfRange);
00251 vector<float>& getXLowerDerivatives() throw() {return x_lower_derivatives_;}
00252 vector<float>& getXUpperDerivatives() throw() {return x_upper_derivatives_;}
00253
00254 void setYLowerDerivative (float ld, bool recompute = true) throw();
00255 void setYUpperDerivative (float ud, bool recompute = true) throw();
00256
00257 float getYLowerDerivative() throw() {return y_lower_derivative_;}
00258 float getYUpperDerivative() throw() {return y_upper_derivative_;}
00259
00260
00261 CubicSpline1D& getSpline(Position i) throw(Exception::OutOfRange);
00262
00263 const CubicSpline1D& getSpline(Position i) const throw(Exception::OutOfRange);
00264 Size getNumberOfSplines() const throw() {return splines_.size();}
00265
00266 private :
00267
00276 void createBiCubicSpline()
00277 throw();
00278
00279
00280
00281 std::vector< std::vector<float> > sample_positions_x_;
00282
00283
00284 std::vector<float> sample_positions_y_;
00285
00286
00287 std::vector<CubicSpline1D> splines_;
00288
00289
00290 std::vector<std::vector<float> > sample_values_;
00291
00292
00293
00294
00295
00296
00297 bool return_average_;
00298
00304 std::vector<float> x_default_values_;
00305
00311 float y_default_value_;
00312
00316 float default_value_;
00317
00318
00319 vector<float> x_lower_bounds_;
00320
00321
00322 vector<float> x_upper_bounds_;
00323
00324
00325 float y_lower_bound_;
00326
00327
00328 float y_upper_bound_;
00329
00330
00331
00332 vector<bool> x_is_natural_;
00333
00334
00335 bool y_is_natural_;
00336
00337
00338
00339 vector<float> x_lower_derivatives_;
00340
00341
00342 vector<float> x_upper_derivatives_;
00343
00344
00345 float y_lower_derivative_;
00346
00347
00348 float y_upper_derivative_;
00349
00351 int verbosity_;
00352 };
00353
00354
00355
00356 }
00357 #endif