9#include <unsupported/Eigen/Splines>
21template <
typename Scalar =
double,
int Degree = 3>
25 using ScalarVector = std::vector<Scalar>;
26 using SplineType = Eigen::Spline<Scalar, 2>;
38 assert(xs.size() == ys.size() &&
"xs and ys must be same length");
40 spline_ = Eigen::SplineFitting<SplineType>::Interpolate(points, Degree);
48 assert(t >= 0 && t <= 1 &&
"t must be in range [0, 1]");
49 Eigen::Vector2d val = spline_(t);
50 return {val(0), val(1)};
63 const ScalarVector& xs,
const ScalarVector& ys)
65 Eigen::MatrixXd mat{2, xs.size()};
66 mat.row(0) = Eigen::VectorXd::Map(xs.data(), xs.size());
67 mat.row(1) = Eigen::VectorXd::Map(ys.data(), ys.size());
77template <
typename Scalar>
Simple spline wrapper around Eigen::Spline.
Pixel operator()(Scalar t) const
Spline evaluation at t-space value t in [0, 1]
Spline(const ScalarVector &xs, const ScalarVector &ys)
Construct a spline by fitting to a set of points.
Eigen::MatrixXd make_wide_matrix_(const ScalarVector &xs, const ScalarVector &ys)
Combine X and Y values into an npoints_ x 2 matrix.
Segmentation algorithms and utilities library