![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
A class for performing simple x-y linear interpolation. More...
#include <Interpolator.h>
Public Member Functions | |
| int16 | setData (const floating_point *x_array_ptr, const floating_point *y_array_ptr, uint32 size) |
| Sets the data for the interpolator. | |
| floating_point | getMinX () const |
| Returns the minimum x-value from the stored data. | |
| floating_point | getMaxX () const |
| Returns the maximum x-value from the stored data. | |
| int16 | interpolate (floating_point x, floating_point &y_out) |
| 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:
| floating_point clockwerk::Interpolator::getMaxX | ( | ) | const |
Returns the maximum x-value from the stored data.
| floating_point clockwerk::Interpolator::getMinX | ( | ) | const |
Returns the minimum x-value from the stored data.
| int16 clockwerk::Interpolator::interpolate | ( | floating_point | x, |
| floating_point & | y_out ) |
Performs linear interpolation given an x-value.
| [in] | x | The x-value for which to interpolate. |
| [out] | y_out | 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.
| int16 clockwerk::Interpolator::setData | ( | const floating_point * | x_array_ptr, |
| const floating_point * | y_array_ptr, | ||
| uint32 | size ) |
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.