18#if EIGEN_VERSION_AT_LEAST(3, 4, 0)
29 auto relativeTime = [tsMin =
_tsMin, tsMax =
_tsMax](
double t) ->
double {
return (t - tsMin) / (tsMax - tsMin); };
30 ts =
ts.unaryExpr(relativeTime);
34 Eigen::KnotAveraging(
ts, splineDegree,
_knots);
35 Eigen::DenseIndex n = xs.cols();
36 Eigen::MatrixXd A = Eigen::MatrixXd::Zero(n, n);
38 for (Eigen::DenseIndex i = 1; i < n - 1; ++i) {
40 const Eigen::DenseIndex
span = Eigen::Spline<double, 1>::Span(
ts[i], splineDegree,
_knots);
43 A.row(i).segment(
span - splineDegree, splineDegree + 1) = Eigen::Spline<double, 1>::BasisFunctions(
ts[i], splineDegree,
_knots);
46 A(n - 1, n - 1) = 1.0;
48 auto qr = A.householderQr();
50 Eigen::MatrixXd controls = Eigen::MatrixXd::Zero(n,
_ndofs);
52 for (
int i = 0; i <
_ndofs; i++) {
53 controls.col(i) = qr.solve(xs.row(i).transpose());
55 _ctrls = std::move(controls);
Bspline(Eigen::VectorXd ts, const Eigen::MatrixXd &xs, int splineDegree)
Initialises the B-Spline interpolation with the given data (x0,t0), (x1,t1), ..., (xn,...