Easy3D 2.6.1
|
Cubic spline interpolation. More...
#include <easy3d/core/spline_interpolation.h>
Public Types | |
enum | BoundaryType { first_deriv = 1 , second_deriv = 2 } |
Boundary condition type. More... | |
Public Member Functions | |
SplineInterpolation () | |
void | set_boundary (BoundaryType left, FT left_value, BoundaryType right, FT right_value, bool linear_extrapolation=false) |
void | set_data (const std::vector< FT > &x, const std::vector< FT > &y, bool cubic_spline=true) |
FT | operator() (FT x) const |
Evaluates the spline at x . | |
FT | derivative (int order, FT x) const |
Returns the order -th derivative of the spline at x. | |
Cubic spline interpolation.
SplineInterpolation generates a piecewise polynomial function of degree 3 and is twice continuously differentiable everywhere. Boundary conditions default to zero-curvature at the end points. It extrapolates linearly, if default boundary conditions are used, or otherwise extrapolation is a quadratic function. The math behind this implementation is described here: https://kluge.in-chemnitz.de/opensource/spline/
Spline interpolation have many applications, e.g., curve interpolation (for any dimensions).
The following code shows how to use SplineInterpolation for 3D curve interpolation.
enum BoundaryType |
|
inline |
Constructor. Sets default boundary condition to be zero curvature at both ends
void set_boundary | ( | BoundaryType | left, |
FT | left_value, | ||
BoundaryType | right, | ||
FT | right_value, | ||
bool | linear_extrapolation = false ) |
Sets the boundary condition (optional).
void set_data | ( | const std::vector< FT > & | x, |
const std::vector< FT > & | y, | ||
bool | cubic_spline = true ) |
Sets the data can carry out the interpolation. true
for cubic spline interpolation; false
for linear interpolation.
x
has to be monotonously increasing.