33 const uint32_t spline_order)
34 : t_knots_(t_knots), spline_order_(spline_order) {
36 (t_knots_.size() > 1 ? 2 * (t_knots_.size() - 1) * (1 + spline_order_)
38 kernel_matrix_ = Eigen::MatrixXd::Zero(total_params_, total_params_);
39 offset_ = Eigen::MatrixXd::Zero(total_params_, 1);
90 kernel_matrix_.block(2 * i * num_params, 2 * i * num_params, num_params,
112 const std::vector<double>& t_coord,
const std::vector<Vec2d>& ref_points,
113 const double weight) {
114 if (ref_points.size() != t_coord.size()) {
118 for (uint32_t i = 0; i < t_coord.size(); ++i) {
119 auto cur_index = find_index(t_coord[i]);
120 double cur_rel_t = t_coord[i] - t_knots_[cur_index];
122 double offset_coef_x = -ref_points[i].x() * weight;
123 double offset_coef_y = -ref_points[i].y() * weight;
124 const uint32_t num_params = spline_order_ + 1;
125 for (uint32_t j = 0; j < num_params; ++j) {
126 offset_(j + (2 * cur_index) * num_params, 0) = offset_coef_x;
127 offset_(j + (2 * cur_index + 1) * num_params, 0) = offset_coef_y;
128 offset_coef_x *= cur_rel_t;
129 offset_coef_y *= cur_rel_t;
133 Eigen::MatrixXd ref_kernel(num_params, num_params);
136 std::vector<double> power_t;
137 for (uint32_t n = 0; n + 1 < 2 * num_params; ++n) {
138 power_t.emplace_back(cur_t);
142 for (uint32_t r = 0; r < num_params; ++r) {
143 for (uint32_t c = 0; c < num_params; ++c) {
144 ref_kernel(r, c) = power_t[r + c];
147 kernel_matrix_.block((2 * cur_index) * num_params,
148 (2 * cur_index) * num_params, num_params,
149 num_params) += weight * ref_kernel;
150 kernel_matrix_.block((2 * cur_index + 1) * num_params,
151 (2 * cur_index + 1) * num_params, num_params,
152 num_params) += weight * ref_kernel;