BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Static Public Attributes | List of all members
BALL::CubicSpline2D Class Reference

#include <BALL/MATHS/cubicSpline2D.h>

Static Public Attributes

static const int VERBOSITY_LEVEL_DEBUG
 
static const int VERBOSITY_LEVEL_CRITICAL
 

Constructors and Destructors.

std::vector< std::vector< float > > sample_positions_x_
 
std::vector< floatsample_positions_y_
 
std::vector< CubicSpline1Dsplines_
 
std::vector< std::vector< float > > sample_values_
 
bool return_average_
 
std::vector< floatx_default_values_
 
float y_default_value_
 
float default_value_
 
vector< floatx_lower_bounds_
 
vector< floatx_upper_bounds_
 
float y_lower_bound_
 
float y_upper_bound_
 
vector< boolx_is_natural_
 
bool y_is_natural_
 
vector< floatx_lower_derivatives_
 
vector< floatx_upper_derivatives_
 
float y_lower_derivative_
 
float y_upper_derivative_
 
int verbosity_
 
 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)
 
 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)
 Set the verbosity of the spline computation and evaluation. More...
 
float operator() (float x, float y)
 
float getXDefaultValue (Index x) const
 
float getYDefaultValue () const
 
void setXDefaultValues (vector< float > x_default_values)
 
void setYDefaultValue (float y_default_value)
 
void setYLowerBound (float lb)
 
void setYUpperBound (float ub)
 
float getYLowerBound ()
 
float getYUpperBound ()
 
void setXLowerBounds (vector< float > lb)
 
void setXUpperBounds (vector< float > ub)
 
const vector< float > & getXLowerBounds () const
 
const vector< float > & getXUpperBounds () const
 
float getXLowerBounds (Index x) const
 
float getXUpperBounds (Index x) const
 
bool isXNatural (Index x)
 
vector< boolisXNatural () const
 
void makeXNatural (Index x, bool recompute=true)
 
void makeAllXNatural (bool recompute=true)
 
void makeYNatural (bool y_is_natural, bool recompute=true)
 
bool isYNatural ()
 
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 ()
 
vector< float > & getXUpperDerivatives ()
 
void setYLowerDerivative (float ld, bool recompute=true)
 
void setYUpperDerivative (float ud, bool recompute=true)
 
float getYLowerDerivative ()
 
float getYUpperDerivative ()
 
CubicSpline1DgetSpline (Position i)
 
const CubicSpline1DgetSpline (Position i) const
 
Size getNumberOfSplines () const
 
void createBiCubicSpline ()
 

Detailed Description

Definition at line 17 of file cubicSpline2D.h.

Constructor & Destructor Documentation

BALL::CubicSpline2D::CubicSpline2D ( )

Default constructor.

BALL::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 
)

Detailed constructor Given the increasingly sorted sample positions { sample_positions_y_} in y direction, increasingly sorted sample positions { sample_positions_x_} in x direction and the corresponding sample values { sample_values} a 2D spline is created by storing for each y sample position the corresponding 1d spline in x direction. By default, we assume the first and the last values to be the lower and upper bounds. If the { return_average_} flag is set to true, the default return values are set to the spline average. If the { is_natural} flag is set to true, all 1D splines and the 1D spline in y direction used in the { operator() } will be natural. Otherwise { x_lower_derivatives} and { x_upper_derivatives} are taken as first derivatives of the first/last sample positions in x direction and { y_lower_derivative} and { y_upper_derivative} are taken as the first derivatives of the first/last derivative in y direction. By default, the derivatives are set to zero.

BALL::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,
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 
)

Detailed constructor Given the increasingly sorted sample positions { sample_positions_y_} in y direction, increasingly sorted sample positions { sample_positions_x_} in x direction and the corresponding sample values { sample_values} a 2D spline is created by storing for each y sample position the corresponding 1d spline in x direction. The { return_average} flag is set to false and the default values { x_default_values_} and { y_default_value_} is set to the given values. The lower and upper bounds in x and y direction are set to the given values. If the { is_natural} flag is set to true, all 1D splines and the 1D spline in y direction used in the { operator() } will be natural. Otherwise { x_lower_derivatives} and { x_upper_derivatives} are taken as first derivatives of the first/last sample positions in x direction and { y_lower_derivative} and { y_upper_derivative} are taken as the first derivatives of the first/last derivative in y direction. By default, the derivatives are set to zero.

BALL::CubicSpline2D::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 
)

Detailed constructor Given the increasingly sorted sample positions { sample_positions_y_} in y direction, increasingly sorted sample positions { sample_positions_x_} in x direction (same for all splines in x direction! ) and the corresponding sample values { sample_values} a 2D spline is created by storing for each y sample position the corresponding 1d spline in x direction. By default, we assume the first and the last values to be the lower and upper bounds. If the { return_average_} flag is set to true, the default return values are set to the spline average. If the { is_natural} flag is set to true, all 1D splines and the 1D spline in y direction used in the { operator() } will be natural. Otherwise { x_lower_derivatives} and { x_upper_derivatives} are taken as first derivatives of the first/last sample positions in x direction and { y_lower_derivative} and { y_upper_derivative} are taken as the first derivatives of the first/last derivative in y direction. By default, the derivatives are set to zero.

BALL::CubicSpline2D::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 
)

Detailed constructor Given the increasingly sorted sample positions { sample_positions_y_} in y direction, increasingly sorted sample positions { sample_positions_x_} in x direction and the corresponding sample values { sample_values} a 2D spline is created by storing for each y sample position the corresponding 1d spline in x direction. The { return_average} flag is set to false and the default values { x_default_values_} and { y_default_value_} is set to the given values. The lower and upper bounds in x and y direction are set to the given values. If the { is_natural} flag is set to true, all 1D splines and the 1D spline in y direction used in the { operator() } will be natural. Otherwise { x_lower_derivatives} and { x_upper_derivatives} are taken as first derivatives of the first/last sample positions in x direction and { y_lower_derivative} and { y_upper_derivative} are taken as the first derivatives of the first/last derivative in y direction. By default, the derivatives are set to zero.

BALL::CubicSpline2D::CubicSpline2D ( const CubicSpline2D cs2D)

Copy constructor.

virtual BALL::CubicSpline2D::~CubicSpline2D ( )
virtual

Destructor.

Member Function Documentation

void BALL::CubicSpline2D::createBiCubicSpline ( )
private

Method to create a 2D cubic spline relying to be given increasingly ordered sample positions in y direction, for each y position increasingly ordered sample positions in x direction, and the corresponding sample values. If the { return_average_} flag is set to true, the { default_value_} is the average of the 1D spline averages, otherwise it is set to std::numeric_limits<float>::min() . By default the boundaries in y direction are set to the lower and the upper y sample position. The { operator ()} returns the 2D interpolation for given x and y values.

Size BALL::CubicSpline2D::getNumberOfSplines ( ) const
inline

Definition at line 289 of file cubicSpline2D.h.

CubicSpline1D& BALL::CubicSpline2D::getSpline ( Position  i)

Return the i-th spline

Exceptions
Exception::OutOfRangeif i >= getNumberOfSplines()
const CubicSpline1D& BALL::CubicSpline2D::getSpline ( Position  i) const

Return the i-th spline

Exceptions
Exception::OutOfRangeif i >= getNumberOfSplines()
float BALL::CubicSpline2D::getXDefaultValue ( Index  x) const

Returns the x-th default value in x direction.

Exceptions
Exception::OutOfRangeif x >= number_of_default_values
const vector<float>& BALL::CubicSpline2D::getXLowerBounds ( ) const
inline

Returns all lower bounds in x direction.

Definition at line 212 of file cubicSpline2D.h.

float BALL::CubicSpline2D::getXLowerBounds ( Index  x) const

Get the lower bounds in x direction

Exceptions
Exception::OutOfRangeif x >= x_lower_bounds_.size()
float BALL::CubicSpline2D::getXLowerDerivatives ( Index  x)

Get the lower derivatives in x direction

Exceptions
Exception::OutOfRangeif x >= x_lower_derivatives_.size()
vector<float>& BALL::CubicSpline2D::getXLowerDerivatives ( )
inline

Definition at line 267 of file cubicSpline2D.h.

const vector<float>& BALL::CubicSpline2D::getXUpperBounds ( ) const
inline

Returns all upper bounds in x direction.

Definition at line 216 of file cubicSpline2D.h.

float BALL::CubicSpline2D::getXUpperBounds ( Index  x) const

Get the upper bounds in x direction

Exceptions
Exception::OutOfRangeif x >= x_upper_bounds_.size()
float BALL::CubicSpline2D::getXUpperDerivatives ( Index  x)

Get the upper derivatives in x direction

Exceptions
Exception::OutOfRangeif x >= x_upper_derivatives_.size()
vector<float>& BALL::CubicSpline2D::getXUpperDerivatives ( )
inline

Definition at line 268 of file cubicSpline2D.h.

float BALL::CubicSpline2D::getYDefaultValue ( ) const
inline

Returns the y-th default value in x direction.

Definition at line 191 of file cubicSpline2D.h.

float BALL::CubicSpline2D::getYLowerBound ( )
inline

Definition at line 204 of file cubicSpline2D.h.

float BALL::CubicSpline2D::getYLowerDerivative ( )
inline

Definition at line 275 of file cubicSpline2D.h.

float BALL::CubicSpline2D::getYUpperBound ( )
inline

Definition at line 205 of file cubicSpline2D.h.

float BALL::CubicSpline2D::getYUpperDerivative ( )
inline

Definition at line 276 of file cubicSpline2D.h.

bool BALL::CubicSpline2D::isXNatural ( Index  x)

Returns true if the x-th spline in x direction is natural. If x is out of bound, std::numeric_limits<float>::min() is returned.

vector<bool> BALL::CubicSpline2D::isXNatural ( ) const
inline

Definition at line 231 of file cubicSpline2D.h.

bool BALL::CubicSpline2D::isYNatural ( )
inline

Returns true if the spline in y direction for each call in { operator ()} is natural.

Definition at line 251 of file cubicSpline2D.h.

void BALL::CubicSpline2D::makeAllXNatural ( bool  recompute = true)

Sets the flag { is_natural_} for all x-th splines to true. By default the method recomputes all splines. If the argument is false, no recomputation is done.

void BALL::CubicSpline2D::makeXNatural ( Index  x,
bool  recompute = true 
)

Sets the flag { is_natural_} for the x-th spline to true. By default the method recomputes the spline. If the argument is false, no recomputation is done.

void BALL::CubicSpline2D::makeYNatural ( bool  y_is_natural,
bool  recompute = true 
)

Sets the flag { y_is_natural_} to true. Since the spline in y direction is created for each call of { operator ()} new, recomputation is not necessary.

float BALL::CubicSpline2D::operator() ( float  x,
float  y 
)

A method to evaluate the 2Dspline at the access values x | y. First all spline in y-direction are evaluated at x. Based on these values a temporary 1D spline is created, which will be evaluated at y. If the access values are out of bound or if we have too less points given for a spline the { default_value} is returned. If the spacing is zero, std::numeric_limits<float>::min() is returned.

void BALL::CubicSpline2D::setVerbosity ( int  verbosity)

Set the verbosity of the spline computation and evaluation.

void BALL::CubicSpline2D::setXDefaultValues ( vector< float x_default_values)
inline

Definition at line 194 of file cubicSpline2D.h.

void BALL::CubicSpline2D::setXLowerBounds ( vector< float lb)
inline

Definition at line 207 of file cubicSpline2D.h.

void BALL::CubicSpline2D::setXLowerDerivatives ( vector< float ld,
bool  recompute = true 
)
void BALL::CubicSpline2D::setXUpperBounds ( vector< float ub)
inline

Definition at line 208 of file cubicSpline2D.h.

void BALL::CubicSpline2D::setXUpperDerivatives ( vector< float ud,
bool  recompute = true 
)
void BALL::CubicSpline2D::setYDefaultValue ( float  y_default_value)
inline

Definition at line 197 of file cubicSpline2D.h.

void BALL::CubicSpline2D::setYLowerBound ( float  lb)
inline

Definition at line 201 of file cubicSpline2D.h.

void BALL::CubicSpline2D::setYLowerDerivative ( float  ld,
bool  recompute = true 
)
void BALL::CubicSpline2D::setYUpperBound ( float  ub)
inline

Definition at line 202 of file cubicSpline2D.h.

void BALL::CubicSpline2D::setYUpperDerivative ( float  ud,
bool  recompute = true 
)

Member Data Documentation

float BALL::CubicSpline2D::default_value_
private

The default value of splines in general. If the return_average_ flag is set to true, the averall average of the splines is computed. Otherwise it is set to std::numeric_limits<float>::min() .

Definition at line 340 of file cubicSpline2D.h.

bool BALL::CubicSpline2D::return_average_
private

Definition at line 321 of file cubicSpline2D.h.

std::vector< std::vector<float> > BALL::CubicSpline2D::sample_positions_x_
private

Definition at line 305 of file cubicSpline2D.h.

std::vector<float> BALL::CubicSpline2D::sample_positions_y_
private

Definition at line 308 of file cubicSpline2D.h.

std::vector<std::vector<float> > BALL::CubicSpline2D::sample_values_
private

Definition at line 314 of file cubicSpline2D.h.

std::vector<CubicSpline1D> BALL::CubicSpline2D::splines_
private

Definition at line 311 of file cubicSpline2D.h.

int BALL::CubicSpline2D::verbosity_
private

Definition at line 375 of file cubicSpline2D.h.

const int BALL::CubicSpline2D::VERBOSITY_LEVEL_CRITICAL
static

Definition at line 22 of file cubicSpline2D.h.

const int BALL::CubicSpline2D::VERBOSITY_LEVEL_DEBUG
static

Definition at line 21 of file cubicSpline2D.h.

std::vector<float> BALL::CubicSpline2D::x_default_values_
private

The default values of the splines in x direction. In case the access-value of the x-th spline in x direction is out of bounds or if too less points are given, the corresponding { default_value_(x)} is returned.

Definition at line 328 of file cubicSpline2D.h.

vector<bool> BALL::CubicSpline2D::x_is_natural_
private

Definition at line 356 of file cubicSpline2D.h.

vector<float> BALL::CubicSpline2D::x_lower_bounds_
private

Definition at line 343 of file cubicSpline2D.h.

vector<float> BALL::CubicSpline2D::x_lower_derivatives_
private

Definition at line 363 of file cubicSpline2D.h.

vector<float> BALL::CubicSpline2D::x_upper_bounds_
private

Definition at line 346 of file cubicSpline2D.h.

vector<float> BALL::CubicSpline2D::x_upper_derivatives_
private

Definition at line 366 of file cubicSpline2D.h.

float BALL::CubicSpline2D::y_default_value_
private

The default value of the splines in y direction. In case the access-value of the y-th spline in y direction is out of bounds or if too less points for this spline are given, the corresponding { default_value_(y)} is returned.

Definition at line 335 of file cubicSpline2D.h.

bool BALL::CubicSpline2D::y_is_natural_
private

Definition at line 359 of file cubicSpline2D.h.

float BALL::CubicSpline2D::y_lower_bound_
private

Definition at line 349 of file cubicSpline2D.h.

float BALL::CubicSpline2D::y_lower_derivative_
private

Definition at line 369 of file cubicSpline2D.h.

float BALL::CubicSpline2D::y_upper_bound_
private

Definition at line 352 of file cubicSpline2D.h.

float BALL::CubicSpline2D::y_upper_derivative_
private

Definition at line 372 of file cubicSpline2D.h.