Implementation of a linear interpolator for piecewise linear function approximation.
More...
|
| | CLinearInterpolator () |
| |
| | CLinearInterpolator (double *positions, double *values, int nodesCount, bool isExtrapolationEnabled=false) |
| |
| void | SetNodes (double *positions, double *values, int nodesCount) |
| |
| virtual bool | InitFromFunction (const ISampledFunction &function) override |
| | Initialize interpolator based on a sample function.
|
| |
| virtual bool | GetValueAt (const double &argument, double &result) const override |
| |
| virtual double | GetValueAt (const double &argument) const override |
| |
| virtual bool | GetValueAt (const Argument &argument, Result &result) const =0 |
| | Get function value for specified argument value.
|
| |
| virtual Result | GetValueAt (const Argument &argument) const =0 |
| | Get function value for specified argument value.
|
| |
| virtual | ~IPolymorphic () |
| |
Implementation of a linear interpolator for piecewise linear function approximation.
Purpose
CLinearInterpolator provides simple and efficient piecewise linear interpolation through a set of data points. It creates straight line segments between consecutive points, offering exact reproduction of linear functions and predictable behavior for all input data. Optional extrapolation extends the function beyond the defined domain using the slopes of the first and last segments.
Characteristics
- Simplicity: Straightforward, predictable behavior
- Efficiency: Fast evaluation, minimal computation
- Exactness: Passes exactly through all data points
- Continuity: C0 continuous (continuous value but not derivative)
- No oscillation: Cannot produce spurious oscillations between points
Usage Examples
double positions[] = {0.0, 1.0, 2.0, 3.0};
double values[] = {0.0, 2.0, 1.5, 3.0};
double result;
if (interp1.GetValueAt(1.5, result)) {
}
double value1 = interp1.GetValueAt(-1.0);
double value2 = interp1.GetValueAt(5.0);
double value3 = interp2.GetValueAt(-1.0);
double value4 = interp2.GetValueAt(5.0);
Implementation of a linear interpolator for piecewise linear function approximation.
When to Use
Use linear interpolation when:
- Data has sharp transitions or discontinuities in derivatives
- Simplicity and predictability are important
- Performance is critical (fastest interpolation method)
- You need exact reproduction at data points
- Data represents piecewise linear relationships
Consider other methods when:
- You need smooth curves (use CAkimaInterpolator or splines)
- Data represents smooth continuous phenomena
- Visual quality matters more than simplicity
- See also
- imath::CAkimaInterpolator, imath::ISampledFunctionInterpolator
Definition at line 76 of file CLinearInterpolator.h.