SuperTuxKart
Loading...
Searching...
No Matches
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.
 
int push_back (float x, float y)
 Adds the value pair x/y to the list of all points.
 
unsigned int size () const
 Returns the number of X/Y points.
 
float getX (unsigned int i) const
 Returns the X value for a specified point.
 
float getY (unsigned int i) const
 Returns the Y value for a specified point.
 
void setY (unsigned int i, float y)
 Sets the Y value for a specified point.
 
float get (float x) const
 Returns the interpolated Y value for a given x.
 
float getReverse (float y) const
 Returns the X value necessary for a specified Y value.
 

Private Attributes

std::vector< float > m_x
 The sorted x values.
 
std::vector< float > m_y
 The y values.
 
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

◆ 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.

◆ 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.

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