![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
A class for performing simple x-y linear interpolation. More...
#include <Interpolate2D.h>
Public Member Functions | |
| int | setData (const std::vector< double > &xValues, const std::vector< double > &yValues) |
| Sets the data for the interpolator. | |
| int | getMinX (double &minX) const |
| Returns the minimum x-value from the stored data. | |
| int | getMaxX (double &maxX) const |
| Returns the maximum x-value from the stored data. | |
| int | interpolate (double x, double &yInterpolated) |
| Performs linear interpolation given an x-value. | |
A class for performing simple x-y linear interpolation.
This class allows you to store tabulated x and y values, and then to compute interpolated y values for any x within the bounds of the stored data. The linear interpolation is performed between successive data points.
Methodology:
Error Handling:
| int warptwin::Interpolate2D::getMaxX | ( | double & | maxX | ) | const |
Returns the maximum x-value from the stored data.
| [out] | maxX | The maximum x-value will be written here if the function succeeds. |
This function returns an error if there is no data stored.
| int warptwin::Interpolate2D::getMinX | ( | double & | minX | ) | const |
Returns the minimum x-value from the stored data.
| [out] | minX | The minimum x-value will be written here if the function succeeds. |
This function returns an error if there is no data stored.
| int warptwin::Interpolate2D::interpolate | ( | double | x, |
| double & | yInterpolated ) |
Performs linear interpolation given an x-value.
| [in] | x | The x-value for which to interpolate. |
| [out] | yInterpolated | The interpolated y-value will be written here if the function succeeds. |
If x is out of the bounds of the stored table, this function returns a non-zero error code. If there are not enough points to perform interpolation, it returns a non-zero error code as well.
| int warptwin::Interpolate2D::setData | ( | const std::vector< double > & | xValues, |
| const std::vector< double > & | yValues ) |
Sets the data for the interpolator.
| xValues | A vector of x-values (must be sorted in ascending order). |
| yValues | A vector of y-values corresponding to xValues. |
This function replaces any previously stored data with the new x and y values. It is required that xValues.size() == yValues.size() and that xValues is sorted in ascending order. If these conditions are not met, a non-zero error code is returned.