HighMap library (C++)
|
A class for performing 1D interpolation using the GSL library. More...
#include <interpolate1d.hpp>
Public Member Functions | |
Interpolator1D (const std::vector< float > &x, const std::vector< float > &y, InterpolationMethod1D method=InterpolationMethod1D::LINEAR) | |
Constructs an Interpolator1D object with the given data and method. | |
~Interpolator1D () | |
Destructor for Interpolator1D . | |
float | operator() (float x) const |
Function call operator for performing interpolation. | |
float | interpolate (float x) const |
Interpolates the value at the specified x coordinate. | |
A class for performing 1D interpolation using the GSL library.
The Interpolator1D
class provides an interface for performing 1D interpolation on a set of data points. The interpolation methods supported are defined by the InterpolationMethod1D
enumeration. The class uses the GSL library for the interpolation computations.
Example
Result
hmap::Interpolator1D::Interpolator1D | ( | const std::vector< float > & | x, |
const std::vector< float > & | y, | ||
InterpolationMethod1D | method = InterpolationMethod1D::LINEAR |
||
) |
Constructs an Interpolator1D
object with the given data and method.
This constructor initializes the interpolation object with the provided x and y data points and the specified interpolation method.
x | A vector of x coordinates (independent variable). |
y | A vector of y coordinates (dependent variable). |
method | The interpolation method to use (default is linear). |
std::invalid_argumentifxandyhavedifferentsizesoriftherearefewerthan | two points. An exception is also thrown if the method requires monotonic data and the provided data is not monotonic. |
hmap::Interpolator1D::~Interpolator1D | ( | ) |
Destructor for Interpolator1D
.
The destructor frees the GSL resources used by the interpolation object.
float hmap::Interpolator1D::operator() | ( | float | x | ) | const |
Function call operator for performing interpolation.
This operator overload allows the Interpolator1D
object to be called as a function, directly returning the interpolated value at the specified x coordinate. It serves as a shorthand for the interpolate()
method.
x | The x coordinate at which to interpolate. |
float hmap::Interpolator1D::interpolate | ( | float | x | ) | const |
Interpolates the value at the specified x coordinate.
This function computes the interpolated y value corresponding to the given x coordinate using the previously specified interpolation method.
x | The x coordinate at which to interpolate. |