2 #include "gtest/gtest.h" 4 #include <boost/concept_check.hpp> 13 class ParamFuncManipSplineDistTest :
public ::testing::Test
19 ParamFuncManipSplineDistTest()
24 virtual ~ParamFuncManipSplineDistTest()
38 virtual void TearDown()
49 TEST_F(ParamFuncManipSplineDistTest, Initialization0)
55 vector<PFS> pf(3, PFS());
56 pf[0].ctrlPtsSize = 5;
57 pf[0].ctrlPtsArcRefIdx = 0;
58 pf[1].ctrlPtsSize = 5;
59 pf[1].ctrlPtsArcRefIdx = 0;
60 pf[2].ctrlPtsSize = 8;
61 pf[2].ctrlPtsArcRefIdx = 1;
78 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
80 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = 10 - 2 * j;
84 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
87 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 2 * j;
90 for (
size_t j = 1; j < funcs->funcCtrlPtSize(funcIdx); j++)
92 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = -2 + 7 * j;
93 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 33 + 3 * j;
97 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 666;
98 funcs->ctrlPtVal(funcIdx, funcs->funcCtrlPtSize(funcIdx) - 1,
PfCpD::ARC) = 555;
100 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 123;
107 EXPECT_EQ(123, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
108 jj = funcs->funcCtrlPtSize(funcIdx) - 1;
109 EXPECT_EQ(555, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
112 EXPECT_EQ(123, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
113 jj = funcs->funcCtrlPtSize(funcIdx) - 1;
114 EXPECT_EQ(555, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
134 vector<PFS> pf(4, PFS());
135 pf[0].ctrlPtsSize = 4;
136 pf[0].ctrlPtsArcRefIdx = 0;
137 pf[1].ctrlPtsSize = 4;
138 pf[1].ctrlPtsArcRefIdx = 0;
139 pf[2].ctrlPtsSize = 7;
140 pf[2].ctrlPtsArcRefIdx = 1;
141 pf[3].ctrlPtsSize = 9;
142 pf[3].ctrlPtsArcRefIdx = 2;
146 pf[0].evalReq[(size_t)
FeM::INT1] =
false;
147 pf[0].evalReq[(size_t)
FeM::INT2] =
false;
152 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
154 funcs->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
156 funcs->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
158 funcs->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
169 void testValDiff(
ParamFuncsSPtr funcs,
double initT,
size_t funcIdx,
double funcShift)
172 EXPECT_DOUBLE_EQ(0 + funcShift, funcs->computeFuncVal(funcIdx));
174 EXPECT_DOUBLE_EQ(1 + funcShift, funcs->computeFuncVal(funcIdx));
175 funcs->setEvalArc(1.5 + initT,
EaG::NONE);
176 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
177 funcs->setEvalArc(2.0 - 1e-5 + initT,
EaG::NONE);
178 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
179 funcs->setEvalArc(2.0 + initT,
EaG::NONE);
180 EXPECT_DOUBLE_EQ(2.0 + funcShift, funcs->computeFuncVal(funcIdx));
181 funcs->setEvalArc(2.0 + 1e-5 + initT,
EaG::NONE);
182 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
183 funcs->setEvalArc(2.5 + initT,
EaG::NONE);
184 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
185 funcs->setEvalArc(3.5 + initT,
EaG::NONE);
186 EXPECT_DOUBLE_EQ(3 + funcShift, funcs->computeFuncVal(funcIdx));
189 funcs->setEvalArc(0 + initT, EaG::AFTER_LAST);
190 EXPECT_DOUBLE_EQ(0 + funcShift, funcs->computeFuncVal(funcIdx));
191 funcs->setEvalArc(1 + initT, EaG::AFTER_LAST);
192 EXPECT_DOUBLE_EQ(1 + funcShift, funcs->computeFuncVal(funcIdx));
193 funcs->setEvalArc(1.5 + initT, EaG::AFTER_LAST);
194 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
195 funcs->setEvalArc(2.0 - 1e-5 + initT, EaG::AFTER_LAST);
196 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
197 funcs->setEvalArc(2.0 + initT, EaG::AFTER_LAST);
198 EXPECT_DOUBLE_EQ(2.0 + funcShift, funcs->computeFuncVal(funcIdx));
199 funcs->setEvalArc(2.0 + 1e-5 + initT, EaG::AFTER_LAST);
200 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
201 funcs->setEvalArc(2.5 + initT, EaG::AFTER_LAST);
202 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
203 funcs->setEvalArc(3.5 + initT, EaG::AFTER_LAST);
204 EXPECT_DOUBLE_EQ(3 + funcShift, funcs->computeFuncVal(funcIdx));
207 funcs->setEvalArc(3.5 + initT, EaG::BEFORE_LAST);
208 EXPECT_DOUBLE_EQ(3 + funcShift, funcs->computeFuncVal(funcIdx));
209 funcs->setEvalArc(2.5 + initT, EaG::BEFORE_LAST);
210 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
211 funcs->setEvalArc(2.0 + 1e-5 + initT, EaG::BEFORE_LAST);
212 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
213 funcs->setEvalArc(2.0 + initT, EaG::BEFORE_LAST);
214 EXPECT_DOUBLE_EQ(2.0 + funcShift, funcs->computeFuncVal(funcIdx));
215 funcs->setEvalArc(2.0 - 1e-5 + initT, EaG::BEFORE_LAST);
216 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
217 funcs->setEvalArc(1.5 + initT, EaG::BEFORE_LAST);
218 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
219 funcs->setEvalArc(1 + initT, EaG::BEFORE_LAST);
220 EXPECT_DOUBLE_EQ(1 + funcShift, funcs->computeFuncVal(funcIdx));
221 funcs->setEvalArc(0 + initT, EaG::BEFORE_LAST);
222 EXPECT_DOUBLE_EQ(0 + funcShift, funcs->computeFuncVal(funcIdx));
226 TEST_F(ParamFuncManipSplineDistTest, evalArcFuncValFuncValDiff1)
232 EvalArcFuncValFuncValDiff1::initValDiff(funcs, initT);
235 EvalArcFuncValFuncValDiff1::testValDiff(funcs, initT, funcIdx, funcShift = 0);
237 EvalArcFuncValFuncValDiff1::testValDiff(funcs, initT, funcIdx, funcShift = 1);
240 TEST_F(ParamFuncManipSplineDistTest, funcValInt1funcValInt2)
247 vector<PFS> pf(4, PFS());
248 pf[0].ctrlPtsSize = 4;
249 pf[0].ctrlPtsArcRefIdx = 0;
250 pf[1].ctrlPtsSize = 4;
251 pf[1].ctrlPtsArcRefIdx = 0;
252 pf[2].ctrlPtsSize = 7;
253 pf[2].ctrlPtsArcRefIdx = 1;
254 pf[3].ctrlPtsSize = 9;
255 pf[3].ctrlPtsArcRefIdx = 2;
263 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
265 funcs->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
267 funcs->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
269 funcs->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
274 EXPECT_DOUBLE_EQ(0, funcs->computeFuncInt1(0));
276 EXPECT_DOUBLE_EQ(0.5, funcs->computeFuncInt1(0));
277 funcs->setEvalArc(2.5 + initT,
EaG::NONE);
278 EXPECT_DOUBLE_EQ(2.875, funcs->computeFuncInt1(0));
279 funcs->setEvalArc(3.5 + initT,
EaG::NONE);
280 EXPECT_DOUBLE_EQ(4.5, funcs->computeFuncInt1(0));
281 funcs->setEvalArc(4.0 + initT,
EaG::NONE);
282 EXPECT_DOUBLE_EQ(6.5, funcs->computeFuncInt1(0));
285 EXPECT_DOUBLE_EQ(0, funcs->computeFuncInt2(0));
287 EXPECT_DOUBLE_EQ(1. / 6., funcs->computeFuncInt2(0));
288 funcs->setEvalArc(2.5 + initT,
EaG::NONE);
289 EXPECT_DOUBLE_EQ(1.5625, funcs->computeFuncInt2(0));
290 funcs->setEvalArc(3.5 + initT,
EaG::NONE);
291 EXPECT_DOUBLE_EQ(2.375, funcs->computeFuncInt2(0));
292 funcs->setEvalArc(4.0 + initT,
EaG::NONE);
293 EXPECT_DOUBLE_EQ(10. / 3., funcs->computeFuncInt2(0));
296 EXPECT_DOUBLE_EQ(1, funcs->computeFuncDiff1(0));
297 funcs->setEvalArc(2 + initT, EaG::AFTER_LAST);
298 EXPECT_DOUBLE_EQ(1, funcs->computeFuncDiff1(0));
305 EXPECT_DOUBLE_EQ(0, funcs2.computeFuncInt1(0));
307 EXPECT_DOUBLE_EQ(0.5, funcs2.computeFuncInt1(0));
308 funcs2.setEvalArc(2.5 + initT,
EaG::NONE);
309 EXPECT_DOUBLE_EQ(2.875, funcs2.computeFuncInt1(0));
310 funcs2.setEvalArc(3.5 + initT,
EaG::NONE);
311 EXPECT_DOUBLE_EQ(4.5, funcs2.computeFuncInt1(0));
312 funcs2.setEvalArc(4.0 + initT,
EaG::NONE);
313 EXPECT_DOUBLE_EQ(6.5, funcs2.computeFuncInt1(0));
316 EXPECT_DOUBLE_EQ(0, funcs2.computeFuncInt2(0));
318 EXPECT_DOUBLE_EQ(1. / 6., funcs2.computeFuncInt2(0));
319 funcs2.setEvalArc(2.5 + initT,
EaG::NONE);
320 EXPECT_DOUBLE_EQ(1.5625, funcs2.computeFuncInt2(0));
321 funcs2.setEvalArc(3.5 + initT,
EaG::NONE);
322 EXPECT_DOUBLE_EQ(2.375, funcs2.computeFuncInt2(0));
323 funcs2.setEvalArc(4.0 + initT,
EaG::NONE);
324 EXPECT_DOUBLE_EQ(10. / 3., funcs2.computeFuncInt2(0));
327 EXPECT_DOUBLE_EQ(1, funcs2.computeFuncDiff1(0));
328 funcs2.setEvalArc(2 + initT, EaG::AFTER_LAST);
329 EXPECT_DOUBLE_EQ(1, funcs2.computeFuncDiff1(0));
337 EXPECT_DOUBLE_EQ(0, funcs3.computeFuncInt1(0));
339 EXPECT_DOUBLE_EQ(0.5, funcs3.computeFuncInt1(0));
340 funcs3.setEvalArc(2.5 + initT,
EaG::NONE);
341 EXPECT_DOUBLE_EQ(2.875, funcs3.computeFuncInt1(0));
342 funcs3.setEvalArc(3.5 + initT,
EaG::NONE);
343 EXPECT_DOUBLE_EQ(4.5, funcs3.computeFuncInt1(0));
344 funcs3.setEvalArc(4.0 + initT,
EaG::NONE);
345 EXPECT_DOUBLE_EQ(6.5, funcs3.computeFuncInt1(0));
348 EXPECT_DOUBLE_EQ(0, funcs3.computeFuncInt2(0));
350 EXPECT_DOUBLE_EQ(1. / 6., funcs3.computeFuncInt2(0));
351 funcs3.setEvalArc(2.5 + initT,
EaG::NONE);
352 EXPECT_DOUBLE_EQ(1.5625, funcs3.computeFuncInt2(0));
353 funcs3.setEvalArc(3.5 + initT,
EaG::NONE);
354 EXPECT_DOUBLE_EQ(2.375, funcs3.computeFuncInt2(0));
355 funcs3.setEvalArc(4.0 + initT,
EaG::NONE);
356 EXPECT_DOUBLE_EQ(10. / 3., funcs3.computeFuncInt2(0));
359 EXPECT_DOUBLE_EQ(1, funcs3.computeFuncDiff1(0));
360 funcs3.setEvalArc(2 + initT, EaG::AFTER_LAST);
361 EXPECT_DOUBLE_EQ(1, funcs3.computeFuncDiff1(0));
367 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_A0)
369 double dt = 1, v = 1, av = 0, dsAnsGiven = 1;
371 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
372 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
373 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
374 EXPECT_DOUBLE_EQ(dt, dtAns);
376 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_A0)
378 double dt = 1, v = -1, av = 0, dsAnsGiven = 1;
380 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
381 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
382 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
383 EXPECT_DOUBLE_EQ(dt, dtAns);
385 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_A0)
387 double dt = -1, v = +1, av = 0, dsAnsGiven = -1;
389 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
390 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
391 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
392 EXPECT_DOUBLE_EQ(dt, dtAns);
394 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_A0)
396 double dt = -1, v = -1, av = 0, dsAnsGiven = -1;
398 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
399 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
400 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
401 EXPECT_DOUBLE_EQ(dt, dtAns);
404 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_APos)
406 double dt = 1, v = 1, av = 1, dsAnsGiven = 1.5;
408 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
409 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
410 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
411 EXPECT_DOUBLE_EQ(dt, dtAns);
413 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_ANeg)
415 double dt = 1, v = -1, av = -1, dsAnsGiven = 1.5;
417 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
418 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
419 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
420 EXPECT_DOUBLE_EQ(dt, dtAns);
422 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_APos)
424 double dt = -1, v = +1, av = +1, dsAnsGiven = -1.5;
426 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
427 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
428 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
429 EXPECT_DOUBLE_EQ(dt, dtAns);
431 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_ANeg)
433 double dt = -1, v = -1, av = -1, dsAnsGiven = -1.5;
435 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
436 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
437 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
438 EXPECT_DOUBLE_EQ(dt, dtAns);
441 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_ANeg_Above0)
443 double dt = 1, v = 1, av = -0.5, dsAnsGiven = 0.75;
445 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
446 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
447 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
448 EXPECT_DOUBLE_EQ(dt, dtAns);
450 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_APos_Below0)
452 double dt = 1, v = -1, av = 0.5, dsAnsGiven = 0.75;
454 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
455 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
456 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
457 EXPECT_DOUBLE_EQ(dt, dtAns);
459 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_ANeg_Above0)
461 double dt = -1, v = 1, av = -0.5, dsAnsGiven = -0.75;
463 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
464 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
465 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
466 EXPECT_DOUBLE_EQ(dt, dtAns);
468 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_APos_Below0)
470 double dt = -1, v = -1, av = 0.5, dsAnsGiven = -0.75;
472 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
473 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
474 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
475 EXPECT_DOUBLE_EQ(dt, dtAns);
478 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_ANeg_Below0_1)
480 double dt = 1, v = 1, av = -1.5, dsAnsGiven = 5. / 12.;
482 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
483 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
484 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
485 EXPECT_DOUBLE_EQ(dt, dtAns);
487 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_APos_Above0_1)
489 double dt = 1, v = -1, av = +1.5, dsAnsGiven = 5. / 12.;
491 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
492 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
493 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
494 EXPECT_DOUBLE_EQ(dt, dtAns);
496 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_ANeg_Below0_1)
498 double dt = -1, v = 1, av = -1.5, dsAnsGiven = -5. / 12.;
500 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
501 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
502 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
503 EXPECT_DOUBLE_EQ(dt, dtAns);
505 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_APos_Above0_1)
507 double dt = -1, v = -1, av = +1.5, dsAnsGiven = -5. / 12.;
509 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
510 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
511 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
512 EXPECT_DOUBLE_EQ(dt, dtAns);
515 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_ANeg_Below0)
517 double dt = 6, v = 3, av = -3.5;
519 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
520 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
521 EXPECT_DOUBLE_EQ(dt, dtAns);
523 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_APos_Above0)
525 double dt = 6, v = -3, av = +3.5;
527 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
528 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
529 EXPECT_DOUBLE_EQ(dt, dtAns);
531 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_ANeg_Below0)
533 double dt = -6, v = 3, av = -3.5;
535 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
536 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
537 EXPECT_DOUBLE_EQ(dt, dtAns);
539 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_APos_Above0)
541 double dt = -6, v = -3, av = +3.5;
543 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
544 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
545 EXPECT_DOUBLE_EQ(dt, dtAns);
549 TEST_F(ParamFuncManipSplineDistTest, distTimeV)
558 vector<PFS> pf(4, PFS());
559 pf[0].ctrlPtsSize = 4;
560 pf[0].ctrlPtsArcRefIdx = 0;
561 pf[1].ctrlPtsSize = 4;
562 pf[1].ctrlPtsArcRefIdx = 0;
563 pf[2].ctrlPtsSize = 7;
564 pf[2].ctrlPtsArcRefIdx = 1;
565 pf[3].ctrlPtsSize = 9;
566 pf[3].ctrlPtsArcRefIdx = 2;
571 vector<size_t> idxCfV(1, 0);
575 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -1;
576 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
577 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
578 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
579 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = -1;
580 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
581 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL) = -5;
582 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
583 funcss->precompute();
585 funcss->setEvalArc(1 + initT,
EaG::NONE);
586 EXPECT_DOUBLE_EQ(0.5, funcss->computeS());
587 EXPECT_DOUBLE_EQ(1 + initT, funcss->computeT(0.5));
588 funcss->setEvalArc(2 + initT,
EaG::NONE);
589 EXPECT_DOUBLE_EQ(1, funcss->computeS());
590 EXPECT_DOUBLE_EQ(2 + initT, funcss->computeT(1));
591 funcss->setEvalArc(3 + initT,
EaG::NONE);
592 EXPECT_DOUBLE_EQ(1.5, funcss->computeS());
593 EXPECT_DOUBLE_EQ(3 + initT, funcss->computeT(1.5));
594 funcss->setEvalArc(3.5 + initT,
EaG::NONE);
595 EXPECT_DOUBLE_EQ(2.5, funcss->computeS());
596 EXPECT_DOUBLE_EQ(3.5 + initT, funcss->computeT(2.5));
597 funcss->setEvalArc(4 + initT,
EaG::NONE);
598 EXPECT_DOUBLE_EQ(4.5, funcss->computeS());
599 EXPECT_DOUBLE_EQ(4 + initT, funcss->computeT(4.5));
601 funcss->setEvalArc(1 + initT,
EaG::NONE);
602 EXPECT_DOUBLE_EQ(0.5, funcss->computeS());
604 EXPECT_DOUBLE_EQ(1 + initT, funcss->computeT(0.5, EaG::AFTER_LAST));
605 EXPECT_DOUBLE_EQ(2 + initT, funcss->computeT(1, EaG::AFTER_LAST));
606 EXPECT_DOUBLE_EQ(3 + initT, funcss->computeT(1.5, EaG::AFTER_LAST));
607 EXPECT_DOUBLE_EQ(3.5 + initT, funcss->computeT(2.5, EaG::AFTER_LAST));
608 EXPECT_DOUBLE_EQ(4 + initT, funcss->computeT(4.5, EaG::AFTER_LAST));
610 funcss->setEvalArc(2 + initT, EaG::AFTER_LAST);
611 EXPECT_DOUBLE_EQ(1, funcss->computeS());
612 funcss->setEvalArc(3 + initT, EaG::AFTER_LAST);
613 EXPECT_DOUBLE_EQ(1.5, funcss->computeS());
614 funcss->setEvalArc(3.5 + initT, EaG::AFTER_LAST);
615 EXPECT_DOUBLE_EQ(2.5, funcss->computeS());
616 funcss->setEvalArc(4 + initT, EaG::AFTER_LAST);
617 EXPECT_DOUBLE_EQ(4.5, funcss->computeS());
620 for (
size_t i = 0; i < 4; i++)
622 funcss->setEvalArc(1 + initT,
EaG::NONE);
623 evalTempSol = funcss->computeFuncVal(i);
625 EXPECT_DOUBLE_EQ(evalTempSol, funcss->computeFuncVal(i));
627 for (
size_t i = 0; i < 4; i++)
629 funcss->setEvalArc(2 + initT,
EaG::NONE);
630 evalTempSol = funcss->computeFuncVal(i);
632 EXPECT_DOUBLE_EQ(evalTempSol, funcss->computeFuncVal(i));
635 vector<double> sLattice(8, 0);
644 vector<double> tLattice(120, 0);
645 funcss->computeS2TLattice(sLattice, tLattice);
647 EXPECT_DOUBLE_EQ(6, tLattice.size());
649 EXPECT_DOUBLE_EQ(0 + initT, tLattice[0]);
650 EXPECT_DOUBLE_EQ(1 + initT, tLattice[1]);
651 EXPECT_DOUBLE_EQ(2 + initT, tLattice[2]);
652 EXPECT_DOUBLE_EQ(3 + initT, tLattice[3]);
653 EXPECT_DOUBLE_EQ(3.5 + initT, tLattice[4]);
654 EXPECT_DOUBLE_EQ(4 + initT, tLattice[5]);
661 funcss->computeS2TLattice(sLattice, tLattice);
663 EXPECT_DOUBLE_EQ(4, tLattice.size());
665 EXPECT_DOUBLE_EQ(0 + initT, tLattice[0]);
666 EXPECT_DOUBLE_EQ(1 + initT, tLattice[1]);
667 EXPECT_DOUBLE_EQ(2 + initT, tLattice[2]);
668 EXPECT_DOUBLE_EQ(4 + initT, tLattice[3]);
673 funcss->computeS2TLattice(sLattice, tLattice);
675 EXPECT_DOUBLE_EQ(2, tLattice.size());
677 EXPECT_DOUBLE_EQ(0 + initT, tLattice[0]);
678 EXPECT_DOUBLE_EQ(4 + initT, tLattice[1]);
681 TEST_F(ParamFuncManipSplineDistTest, timeShift)
689 vector<PFS> pf(4, PFS());
690 pf[0].ctrlPtsSize = 4;
691 pf[0].ctrlPtsArcRefIdx = 0;
692 pf[1].ctrlPtsSize = 4;
693 pf[1].ctrlPtsArcRefIdx = 0;
694 pf[2].ctrlPtsSize = 3;
695 pf[2].ctrlPtsArcRefIdx = 1;
696 pf[3].ctrlPtsSize = 3;
697 pf[3].ctrlPtsArcRefIdx = 2;
702 vector<size_t> idxCfV(1, 0);
707 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -1;
708 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
709 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
710 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
711 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = 0;
712 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
713 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL) = -5;
714 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
716 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = 0;
717 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
718 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
719 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
720 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = -1;
721 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
722 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL) = -5;
723 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
725 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -10;
726 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
727 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 6;
728 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
729 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = 0;
730 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 4 + initT;
732 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -1;
733 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
734 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
735 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
736 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = -1;
737 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 4 + initT;
738 funcss->precompute();
742 funcss->shiftStartCtrlPt(shift);
744 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
745 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
746 EXPECT_DOUBLE_EQ(1, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
747 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
748 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
749 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
750 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
751 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
754 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
755 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
756 EXPECT_DOUBLE_EQ(1, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
757 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
758 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
759 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
760 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
761 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
764 EXPECT_DOUBLE_EQ(-2, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
765 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
766 EXPECT_DOUBLE_EQ(6, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
767 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
768 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
769 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
772 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
773 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
774 EXPECT_DOUBLE_EQ(1, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
775 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
776 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
777 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
780 funcss->shiftStartCtrlPt(shift);
782 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
783 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
784 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
785 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
786 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
787 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
788 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
789 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
792 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
793 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
794 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
795 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
796 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
797 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
798 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
799 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
802 EXPECT_DOUBLE_EQ(4.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
803 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
804 EXPECT_DOUBLE_EQ(4.5, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
805 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
806 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
807 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
810 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
811 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
812 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
813 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
814 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
815 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
866 int main(
int argc,
char **argv)
868 ::testing::InitGoogleTest(&argc, argv);
869 return RUN_ALL_TESTS();
TEST(TestStateMap, CopyAssignmentOperatorArray)
std::shared_ptr< ParamFuncs > ParamFuncsSPtr
control point arc parameter
Helper function needed to upgrade c++ 2011.
int main(int argc, char **argv)
function second derivative
EvalArcGuarantee
Flags if any guarantees about evaluation arc relative to last evaluation arc are present.
Containts parametric function initialization data.
virtual void precompute() override
Precomputes cached data. To be called after ANY control point modifications.
CtrlPtDim
Control point variable dimension.
FuncEvalMode
Required type of computation relative to the parametric function.
std::shared_ptr< ParamFuncsSpline0Dist > ParamFuncsSpline0DistPtr
agent base center linear velocity is parametric function
function first derivative