A helper class to perform Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) interpolation. More...
#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode/PchipInterpolatorHelper.hpp>
Public Member Functions | |
| PchipInterpolatorHelper ()=default | |
| Default constructor. | |
| PchipInterpolatorHelper (const std::vector< double > &x, const std::vector< double > &y) | |
| Constructs the PCHIP interpolator with given data points. | |
| void | setData (const std::vector< double > &x, const std::vector< double > &y) |
| Sets the data points for the interpolator. | |
| double | interpolate (double xi) const |
| Interpolates the value at a given point. | |
Private Member Functions | |
| void | computePCHIP () |
| Computes the PCHIP coefficients. | |
| void | sortData () |
| Sorts the data points by x-coordinate. | |
| double | h (int i) const |
| Computes the difference between successive x-coordinates. | |
| double | delta (int i) const |
| Computes the slope of the segment between successive data points. | |
Private Attributes | |
| std::vector< double > | x_ |
| The x-coordinates of the data points. | |
| std::vector< double > | y_ |
| The y-coordinates of the data points. | |
| std::vector< double > | h_ |
| The differences between successive x-coordinates. | |
| std::vector< double > | delta_ |
| The slopes of the segments between successive data points. | |
| std::vector< double > | d_ |
| The derivatives at the data points. | |
A helper class to perform Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) interpolation.
|
default |
Default constructor.
| PchipInterpolatorHelper::PchipInterpolatorHelper | ( | const std::vector< double > & | x, |
| const std::vector< double > & | y ) |
Constructs the PCHIP interpolator with given data points.
| x | The x-coordinates of the data points. |
| y | The y-coordinates of the data points. |
References setData().
|
private |
Computes the PCHIP coefficients.
References d_, delta(), delta_, h(), h_, and x_.
Referenced by setData().
|
inlineprivate |
Computes the slope of the segment between successive data points.
| i | The index of the segment. |
Referenced by computePCHIP().
|
inlineprivate |
Computes the difference between successive x-coordinates.
| i | The index of the x-coordinate. |
References x_.
Referenced by computePCHIP(), and delta().
| double PchipInterpolatorHelper::interpolate | ( | double | xi | ) | const |
Interpolates the value at a given point.
| xi | The x-coordinate at which to interpolate. |
References d_, h_, x_, and y_.
Referenced by AdaptivePAInterpolator::operator()().
| void PchipInterpolatorHelper::setData | ( | const std::vector< double > & | x, |
| const std::vector< double > & | y ) |
Sets the data points for the interpolator.
| x | The x-coordinates of the data points. |
| y | The y-coordinates of the data points. |
| std::invalid_argument | if x and y have different sizes or if they contain fewer than two points. |
References computePCHIP(), sortData(), x_, and y_.
Referenced by PchipInterpolatorHelper().
|
private |
Sorts the data points by x-coordinate.
Referenced by setData().
|
private |
The derivatives at the data points.
Referenced by computePCHIP(), and interpolate().
|
private |
The slopes of the segments between successive data points.
Referenced by computePCHIP().
|
private |
The differences between successive x-coordinates.
Referenced by computePCHIP(), and interpolate().
|
private |
The x-coordinates of the data points.
Referenced by computePCHIP(), h(), interpolate(), setData(), and sortData().
|
private |
The y-coordinates of the data points.
Referenced by delta(), interpolate(), setData(), and sortData().