17#ifndef __math_cubic_spline_h__
18#define __math_cubic_spline_h__
34 using BasisMatrix = Eigen::Matrix<T, 4, 4>;
35 using WeightVector = Eigen::Matrix<T, 1, 4>;
36 WeightVector weights, deriv_weights;
38 void set (T position) {
39 (this->*(_internal_set)) (position);
42 T coef (
size_t i)
const {
55 switch (processType) {
57 _internal_set = &CubicSpline::_set_value;
62 _internal_set = &CubicSpline::_set_value_deriv;
76 inline void _set_value (T position) {
78 const auto vec = WeightVector (p2 * position, p2, position, 1.0);
82 inline void _set_value_deriv (T position) {
84 const auto vec = WeightVector (position * p2, p2, position, 1.0);
96 static const BasisMatrix hermite_basis_mtrx;
97 static const BasisMatrix hermite_derivative_basis_mtrx;
100 :
CubicSpline<T> (processType, hermite_basis_mtrx, hermite_derivative_basis_mtrx) {}
109 static const BasisMatrix uniform_bspline_basis_mtrx;
110 static const BasisMatrix uniform_bspline_derivative_basis_mtrx;
113 :
CubicSpline<T> (processType, uniform_bspline_basis_mtrx, uniform_bspline_derivative_basis_mtrx) {}
119 template <
typename T>
125 0, 0, 1, 0).finished());
129 template <
typename T>
132 -0.5, 1.5, -1.5, 0.5,
135 0, 1, 0, 0).finished());
137 template <
typename T>
143 template <
typename T>
149 1, 4, 1, 0).finished());
151 template <
typename T>
static const BasisMatrix cubic_poly_derivative_operator
CubicSpline(SplineProcessingType processType, const BasisMatrix basis_matrix, const BasisMatrix deriv_basis_matrix)
const BasisMatrix deriv_basis_matrix
const BasisMatrix basis_matrix
constexpr T pow2(const T &v)