SuperTuxKart
Public Member Functions | Private Attributes | List of all members
InterpolationArray Class Reference

This class manages a set of (x_i,y_i) points, x_i must be sorted. More...

#include <interpolation_array.hpp>

Public Member Functions

void clear ()
 Removes all saved values from this object. More...
 
int push_back (float x, float y)
 Adds the value pair x/y to the list of all points. More...
 
unsigned int size () const
 Returns the number of X/Y points. More...
 
float getX (unsigned int i) const
 Returns the X value for a specified point. More...
 
float getY (unsigned int i) const
 Returns the Y value for a specified point. More...
 
void setY (unsigned int i, float y)
 Sets the Y value for a specified point. More...
 
float get (float x) const
 Returns the interpolated Y value for a given x. More...
 
float getReverse (float y) const
 Returns the X value necessary for a specified Y value. More...
 

Private Attributes

std::vector< float > m_x
 The sorted x values. More...
 
std::vector< float > m_y
 The y values. More...
 
std::vector< float > m_delta
 

Detailed Description

This class manages a set of (x_i,y_i) points, x_i must be sorted.

Those values are then used to linearly interpolate the y value for a given x. If x is less than the minimum x_0, y_0 is returned, if x is more than the maximum x_n, y_n is returned.

Member Function Documentation

◆ clear()

void InterpolationArray::clear ( )
inline

Removes all saved values from this object.

◆ get()

float InterpolationArray::get ( float  x) const
inline

Returns the interpolated Y value for a given x.

◆ getReverse()

float InterpolationArray::getReverse ( float  y) const
inline

Returns the X value necessary for a specified Y value.

If it's not possible to find a corresponding X (y is too small or too large), x_min or x_max is returned.

◆ getX()

float InterpolationArray::getX ( unsigned int  i) const
inline

Returns the X value for a specified point.

◆ getY()

float InterpolationArray::getY ( unsigned int  i) const
inline

Returns the Y value for a specified point.

◆ push_back()

int InterpolationArray::push_back ( float  x,
float  y 
)
inline

Adds the value pair x/y to the list of all points.

It is tested that the x values are added in order.

Parameters
x,yThe pair to add.
Returns
0 If the x values are not sorted, 1 otherwise.

◆ setY()

void InterpolationArray::setY ( unsigned int  i,
float  y 
)
inline

Sets the Y value for a specified point.

◆ size()

unsigned int InterpolationArray::size ( ) const
inline

Returns the number of X/Y points.

Member Data Documentation

◆ m_x

std::vector<float> InterpolationArray::m_x
private

The sorted x values.

◆ m_y

std::vector<float> InterpolationArray::m_y
private

The y values.


The documentation for this class was generated from the following file: