Loading...
Searching...
No Matches
cubicSpline2D.h
Go to the documentation of this file.
#ifndef BALL_MATHS_CUBICSPLINE2D_H
#define BALL_MATHS_CUBICSPLINE2D_H
#include <set>
#include <map>
#ifndef BALL_MATHS_CUBICSPLINE1D_H
# include <BALL/MATHS/cubicSpline1D.h>
#endif
#ifndef BALL_COMMON_EXCEPTION_H
#include <BALL/COMMON/exception.h>
#endif
namespace BALL
{
class BALL_EXPORT CubicSpline2D
{
public:
static const int VERBOSITY_LEVEL_DEBUG;
static const int VERBOSITY_LEVEL_CRITICAL;
BALL_CREATE(CubicSpline2D)
//@}
CubicSpline2D();
CubicSpline2D(const std::vector<std::vector<float> >& sample_positions_x,
const std::vector<float>& sample_positions_y,
const std::vector<std::vector<float> >& sample_values,
bool return_average = false,
bool is_natural = true,
const std::vector<float>& x_lower_derivatives = std::vector<float>(),
const std::vector<float>& x_upper_derivatives = std::vector<float>(),
float y_lower_derivative = 0.,
float y_upper_derivative = 0.,
int verbosity = VERBOSITY_LEVEL_DEBUG);
CubicSpline2D(const std::vector<std::vector<float> >& sample_positions_x,
const std::vector<float>& sample_positions_y,
const std::vector<std::vector<float> >& sample_values,
const std::vector<float>& x_default_values,
float y_default_value,
const std::vector<float>& x_lower_bounds,
const std::vector<float>& x_upper_bounds,
float y_lower_bound,
float y_upper_bound,
bool is_natural = true,
const std::vector<float>& x_lower_derivatives = std::vector<float>(),
const std::vector<float>& x_upper_derivatives = std::vector<float>(),
float y_lower_derivative = 0.0,
float y_upper_derivative = 0.0,
int verbosity = VERBOSITY_LEVEL_DEBUG);
//-------------------------- Constructors with equal x sample positions for all y ------------------------
//Assumes that all rows have the same x-positions.
CubicSpline2D(const std::vector<float>& sample_positions_x,
const std::vector<float>& sample_positions_y,
const std::vector<std::vector<float> >& sample_values,
bool return_average = false,
bool is_natural = true,
const std::vector<float>& x_lower_derivatives = std::vector<float>(),
const std::vector<float>& x_upper_derivatives = std::vector<float>(),
float y_lower_derivative = 0.,
float y_upper_derivative = 0.,
int verbosity = VERBOSITY_LEVEL_DEBUG);
CubicSpline2D(const std::vector<float>& sample_positions_x,
const std::vector<float>& sample_positions_y,
const std::vector<std::vector<float> >& sample_values,
const std::vector<float>& x_default_values,
float y_default_value,
const std::vector<float>& x_lower_bounds,
const std::vector<float>& x_upper_bounds,
float y_lower_bound,
float y_upper_bound,
bool is_natural = true,
const std::vector<float>& x_lower_derivatives = std::vector<float>(),
const std::vector<float>& x_upper_derivatives = std::vector<float>(),
float y_lower_derivative = 0.0,
float y_upper_derivative = 0.0,
int verbosity = VERBOSITY_LEVEL_DEBUG);
CubicSpline2D(const CubicSpline2D& cs2D);
virtual ~CubicSpline2D();
void setVerbosity(int verbosity);
float operator () (float x, float y);
float getXDefaultValue(Index x) const;
float getYDefaultValue() const {return y_default_value_;}
// Set the default values in x direction.
void setXDefaultValues(vector<float> x_default_values) {x_default_values_ = x_default_values;}
// Set the default values in y direction.
void setYDefaultValue(float y_default_value) {y_default_value_ = y_default_value;}
// Set the lower/upper bound in y direction
void setYLowerBound(float lb) {y_lower_bound_ = lb;}
void setYUpperBound(float ub) {y_upper_bound_ = ub;}
// Get the lower/upper bound in y direction
float getYLowerBound() {return y_lower_bound_;}
float getYUpperBound() {return y_upper_bound_;}
// Set the lower/upper bounds in x direction
void setXLowerBounds(vector<float> lb) {x_lower_bounds_ = lb;}
void setXUpperBounds(vector<float> ub) {x_upper_bounds_ = ub;}
const vector<float>& getXLowerBounds() const {return x_lower_bounds_ ;}
const vector<float>& getXUpperBounds() const {return x_upper_bounds_;}
float getXLowerBounds(Index x) const;
float getXUpperBounds(Index x) const;
bool isXNatural(Index x);
vector<bool> isXNatural() const {return x_is_natural_;}
void makeXNatural(Index x, bool recompute = true);
void makeAllXNatural(bool recompute = true);
void makeYNatural(bool y_is_natural, bool recompute = true);
bool isYNatural() {return y_is_natural_;}
// Set the lower/upper derivatives in x direction
void setXLowerDerivatives(vector<float> ld, bool recompute = true);
void setXUpperDerivatives(vector<float> ud, bool recompute = true);
float getXLowerDerivatives(Index x);
float getXUpperDerivatives(Index x);
vector<float>& getXLowerDerivatives() {return x_lower_derivatives_;}
vector<float>& getXUpperDerivatives() {return x_upper_derivatives_;}
// Set the lower/upper derivative in y direction
void setYLowerDerivative (float ld, bool recompute = true);
void setYUpperDerivative (float ud, bool recompute = true);
// Get the lower/upper derivative in y direction
float getYLowerDerivative() {return y_lower_derivative_;}
float getYUpperDerivative() {return y_upper_derivative_;}
CubicSpline1D& getSpline(Position i);
const CubicSpline1D& getSpline(Position i) const;
Size getNumberOfSplines() const {return splines_.size();}
private :
void createBiCubicSpline();
// Sample x positions of the spline.
// Note: we allow for each y value different x positions.
std::vector< std::vector<float> > sample_positions_x_;
// Sample y positions of the spline.
std::vector<float> sample_positions_y_;
// For each y position a 1D cubic spline is stored.
std::vector<CubicSpline1D> splines_;
// Sample values of the spline.
std::vector<std::vector<float> > sample_values_;
//
// Parameters
//
// Flag to denote, if the default values should be set to the average of the spline averages.
bool return_average_;
std::vector<float> x_default_values_;
float y_default_value_;
float default_value_;
// Lower bounds of the spline in x direction.
vector<float> x_lower_bounds_;
// Upper bounds of the spline in x direction.
vector<float> x_upper_bounds_;
// Lower bound of the splines in y direction.
float y_lower_bound_;
// Upper bound of the splines in y direction.
float y_upper_bound_;
// Flag to denote, if the splines in x direction is natural.
vector<bool> x_is_natural_;
// Flag to denote, if the splines in y direction are natural.
bool y_is_natural_;
// Values of the first derivatives of the lower x sample position
vector<float> x_lower_derivatives_;
// Values of the first derivatives of the upper x sample position
vector<float> x_upper_derivatives_;
// Value of the first derivatives of the lower y sample position
float y_lower_derivative_;
// Value of the first derivatives of the upper y sample position
float y_upper_derivative_;
int verbosity_;
};
}
#endif
exception.h
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::CubicSpline1D
Definition cubicSpline1D.h:19
BALL::CubicSpline2D::VERBOSITY_LEVEL_CRITICAL
static const int VERBOSITY_LEVEL_CRITICAL
Definition cubicSpline2D.h:22
BALL::CubicSpline2D::setYDefaultValue
void setYDefaultValue(float y_default_value)
Definition cubicSpline2D.h:197
BALL::CubicSpline2D::makeAllXNatural
void makeAllXNatural(bool recompute=true)
BALL::CubicSpline2D::getYUpperDerivative
float getYUpperDerivative()
Definition cubicSpline2D.h:276
BALL::CubicSpline2D::getXUpperBounds
float getXUpperBounds(Index x) const
BALL::CubicSpline2D::getXLowerBounds
float getXLowerBounds(Index x) const
BALL::CubicSpline2D::setYUpperBound
void setYUpperBound(float ub)
Definition cubicSpline2D.h:202
BALL::CubicSpline2D::getNumberOfSplines
Size getNumberOfSplines() const
Definition cubicSpline2D.h:289
BALL::CubicSpline2D::setYLowerBound
void setYLowerBound(float lb)
Definition cubicSpline2D.h:201
BALL::CubicSpline2D::getYLowerDerivative
float getYLowerDerivative()
Definition cubicSpline2D.h:275
BALL::CubicSpline2D::setXLowerDerivatives
void setXLowerDerivatives(vector< float > ld, bool recompute=true)
BALL::CubicSpline2D::isXNatural
vector< bool > isXNatural() const
Definition cubicSpline2D.h:231
BALL::CubicSpline2D::setYUpperDerivative
void setYUpperDerivative(float ud, bool recompute=true)
BALL::CubicSpline2D::getSpline
CubicSpline1D & getSpline(Position i)
BALL::CubicSpline2D::getXUpperDerivatives
float getXUpperDerivatives(Index x)
BALL::CubicSpline2D::setYLowerDerivative
void setYLowerDerivative(float ld, bool recompute=true)
BALL::CubicSpline2D::getYUpperBound
float getYUpperBound()
Definition cubicSpline2D.h:205
BALL::CubicSpline2D::getXDefaultValue
float getXDefaultValue(Index x) const
BALL::CubicSpline2D::makeXNatural
void makeXNatural(Index x, bool recompute=true)
BALL::CubicSpline2D::setXLowerBounds
void setXLowerBounds(vector< float > lb)
Definition cubicSpline2D.h:207
BALL::CubicSpline2D::setVerbosity
void setVerbosity(int verbosity)
Set the verbosity of the spline computation and evaluation.
BALL::CubicSpline2D::getXLowerBounds
const vector< float > & getXLowerBounds() const
Definition cubicSpline2D.h:212
BALL::CubicSpline2D::isYNatural
bool isYNatural()
Definition cubicSpline2D.h:251
BALL::CubicSpline2D::getYLowerBound
float getYLowerBound()
Definition cubicSpline2D.h:204
BALL::CubicSpline2D::CubicSpline2D
CubicSpline2D()
BALL::CubicSpline2D::getYDefaultValue
float getYDefaultValue() const
Definition cubicSpline2D.h:191
BALL::CubicSpline2D::getSpline
const CubicSpline1D & getSpline(Position i) const
BALL::CubicSpline2D::setXDefaultValues
void setXDefaultValues(vector< float > x_default_values)
Definition cubicSpline2D.h:194
BALL::CubicSpline2D::isXNatural
bool isXNatural(Index x)
BALL::CubicSpline2D::getXLowerDerivatives
vector< float > & getXLowerDerivatives()
Definition cubicSpline2D.h:267
BALL::CubicSpline2D::getXUpperDerivatives
vector< float > & getXUpperDerivatives()
Definition cubicSpline2D.h:268
BALL::CubicSpline2D::VERBOSITY_LEVEL_DEBUG
static const int VERBOSITY_LEVEL_DEBUG
Definition cubicSpline2D.h:21
BALL::CubicSpline2D::getXLowerDerivatives
float getXLowerDerivatives(Index x)
BALL::CubicSpline2D::setXUpperBounds
void setXUpperBounds(vector< float > ub)
Definition cubicSpline2D.h:208
BALL::CubicSpline2D::makeYNatural
void makeYNatural(bool y_is_natural, bool recompute=true)
BALL::CubicSpline2D::getXUpperBounds
const vector< float > & getXUpperBounds() const
Definition cubicSpline2D.h:216
BALL::CubicSpline2D::setXUpperDerivatives
void setXUpperDerivatives(vector< float > ud, bool recompute=true)
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
cubicSpline1D.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105
std
STL namespace.