17 const std::string type = params[
"type"];
18 std::shared_ptr<Interpolation> res =
nullptr;
21 res = std::make_shared<NoInterpolation>();
22 else if (type ==
"linear")
23 res = std::make_shared<LinearInterpolation>();
24 else if (type ==
"linear_ramp")
25 res = std::make_shared<LinearRamp>();
26 else if (type ==
"piecewise_constant")
27 res = std::make_shared<PiecewiseConstantInterpolation>();
28 else if (type ==
"piecewise_linear")
29 res = std::make_shared<PiecewiseLinearInterpolation>();
30 else if (type ==
"piecewise_cubic")
31 res = std::make_shared<PiecewiseCubicInterpolation>();
35 assert(res !=
nullptr);
162 const int N =
points_.size() - 1;
163 Eigen::MatrixXd A = Eigen::MatrixXd::Zero(4 * N, 4 * N);
164 Eigen::VectorXd b = Eigen::VectorXd::Zero(4 * N);
167 for (
int i = 0; i < N; i++)
169 for (
int j = 0; j < 2; j++)
172 const double t =
points_[i + j];
174 A(2 * i + j, 4 * i + 0) = pow(t, 3);
175 A(2 * i + j, 4 * i + 1) = pow(t, 2);
176 A(2 * i + j, 4 * i + 2) = t;
177 A(2 * i + j, 4 * i + 3) = 1;
186 for (
int i = 0; i < N - 1; i++)
189 const double t =
points_[i + 1];
191 A(offset + i, 4 * i + 0) = 3 * pow(t, 2);
192 A(offset + i, 4 * i + 1) = 2 * t;
193 A(offset + i, 4 * i + 2) = 1;
195 A.block<1, 3>(offset + i, 4 * (i + 1)) = -A.block<1, 3>(offset + i, 4 * i);
201 for (
int i = 0; i < N - 1; i++)
204 const double t =
points_[i + 1];
206 A(offset + i, 4 * i + 0) = 6 * t;
207 A(offset + i, 4 * i + 1) = 2;
209 A.block<1, 2>(offset + i, 4 * (i + 1)) = -A.block<1, 2>(offset + i, 4 * i);
218 A(offset, 0) = 3 * pow(
points_[0], 2);
224 A(offset, 4 * (N - 1) + 0) = 3 * pow(
points_[N], 2);
225 A(offset, 4 * (N - 1) + 1) = 2 *
points_[N];
226 A(offset, 4 * (N - 1) + 2) = 1;
238 A(offset, 4 * (N - 1) + 0) = 6 *
points_[N];
239 A(offset, 4 * (N - 1) + 1) = 2;
248 A(offset, 0) = 3 * pow(
points_[0], 2);
251 A(offset, 4 * (N - 1) + 0) = -3 * pow(
points_[N], 2);
252 A(offset, 4 * (N - 1) + 1) = -2 *
points_[N];
253 A(offset, 4 * (N - 1) + 2) = -1;
258 A(offset, 4 * (N - 1) + 0) = -6 *
points_[N];
259 A(offset, 4 * (N - 1) + 1) = -2;
263 assert(offset == 4 * N);