Skip to content

swvanbuuren/cubinterpp

Repository files navigation

cubinterpp - ND Cubic interpolation in C++

N-dimensional cubic and linear interpolation in modern C++ with Python support.

2D parametric periodic spline
2D parametric periodic cubic interpolation using the red points resulting in a distorted torus

Key features

This C++ header library features tools for piecewise linear and cubic interpolation of rectangular grid data in N dimensions.

For cubic piecewise interpolation, the library features three types:

  • Monotone cubic interpolation
  • Modified Akima spline interpolation
  • Natural cubic spline interpolation, with the following boundary conditions:
    • Not-A-Knot (first and second cell at ends share same polynomial)
    • Natural (vanishing second derivative at ends)
    • Clamped (vanishing first derivative at ends)
    • Periodic (value, first and second derivative match for ends)

All classes are templatized and support the STL's vector types.

The accompanying python scripts in cubinterpp and example page compare the interpolation types.

Refer to the documentation for:

Pre-commit hooks

This repository comes with pre-commit hooks. To enable the hooks issue:

uv run pre-commit install --install-hooks

License

An MIT style license applies for cubinterpp, see the LICENSE file for more details.