Class CubicSpline1d

Class Documentation

class CubicSpline1d

Class for computing a one-dimensional cubic spline interpolation. Creates a smooth curve through a series of points (x, y) and provides methods to evaluate positions, first derivatives, and second derivatives along the spline.

Public Functions

CubicSpline1d()

Default constructor for CubicSpline1d. Initializes an empty 1D spline.

void initialize(const std::vector<float> &x, const std::vector<float> &y)

Initializes the 1D spline with the given x and y coordinates.

Parameters:
  • x – Vector of x coordinates.

  • y – Vector of y coordinates.

std::tuple<float, float, float> get_pos_and_derivatives(const float &x)

Calculates the interpolated position and derivatives at a given x.

Parameters:

x – The x position at which to evaluate.

Returns:

Tuple containing (position, first derivative, second derivative).

std::tuple<float, float> get_derivatives(const float &x)

Calculates the first and second derivatives at a given x.

Parameters:

x – The x position at which to evaluate.

Returns:

Tuple containing (first derivative, second derivative).

float calc_position(const float &x)

Calculates the interpolated position at a given x.

Parameters:

x – The x position at which to evaluate.

Returns:

The interpolated y position.