2 #include "gtest/gtest.h" 4 #include <boost/concept_check.hpp> 14 using ParamFuncsSPtr = std::shared_ptr<ParamFuncsBaseVirt<double>>;
15 using ParamFuncsExtTypePtr = std::shared_ptr<ParamFuncsExtType>;
18 class ParamFuncManipSplineDistTest :
public ::testing::Test
24 ParamFuncManipSplineDistTest()
26 funcs = std::shared_ptr<ParamFuncsExtType>(
new ParamFuncsExtType);
29 virtual ~ParamFuncManipSplineDistTest()
43 virtual void TearDown()
54 TEST_F(ParamFuncManipSplineDistTest, Initialization0)
60 vector<PFS> pf(3, PFS());
61 pf[0].ctrlPtsSize = 5;
62 pf[0].ctrlPtsArcRefIdx = 0;
63 pf[1].ctrlPtsSize = 5;
64 pf[1].ctrlPtsArcRefIdx = 0;
65 pf[2].ctrlPtsSize = 8;
66 pf[2].ctrlPtsArcRefIdx = 1;
83 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
85 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = 10 - 2 * j;
89 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
92 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 2 * j;
95 for (
size_t j = 1; j < funcs->funcCtrlPtSize(funcIdx); j++)
97 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = -2 + 7 * j;
98 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 33 + 3 * j;
102 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 666;
103 funcs->ctrlPtVal(funcIdx, funcs->funcCtrlPtSize(funcIdx) - 1,
PfCpD::ARC) = 555;
105 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 123;
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));
117 EXPECT_EQ(123, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
118 jj = funcs->funcCtrlPtSize(funcIdx) - 1;
119 EXPECT_EQ(555, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
129 TEST_F(ParamFuncManipSplineDistTest, Initialization0FuncStatic)
137 vector<PFS> pf(3, PFS());
138 pf[0].ctrlPtsSize = 5;
139 pf[0].ctrlPtsArcRefIdx = 0;
140 pf[1].ctrlPtsSize = 5;
141 pf[1].ctrlPtsArcRefIdx = 0;
142 pf[2].ctrlPtsSize = 8;
143 pf[2].ctrlPtsArcRefIdx = 1;
147 pf[0].evalReq[(size_t)
FeM::INT1] =
false;
148 pf[0].evalReq[(size_t)
FeM::INT2] =
false;
151 pf[1].evalReq[(size_t)
FeM::INT1] =
false;
152 pf[1].evalReq[(size_t)
FeM::INT2] =
false;
155 pf[2].evalReq[(size_t)
FeM::INT1] =
false;
156 pf[2].evalReq[(size_t)
FeM::INT2] =
false;
160 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
162 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = 10 - 2 * j;
166 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
169 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 2 * j;
172 for (
size_t j = 1; j < funcs->funcCtrlPtSize(funcIdx); j++)
174 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = -2 + 7 * j;
175 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 33 + 3 * j;
179 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 666;
180 funcs->ctrlPtVal(funcIdx, funcs->funcCtrlPtSize(funcIdx) - 1,
PfCpD::ARC) = 555;
182 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 123;
189 EXPECT_EQ(123, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
190 jj = funcs->funcCtrlPtSize(funcIdx) - 1;
191 EXPECT_EQ(555, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
194 EXPECT_EQ(123, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
195 jj = funcs->funcCtrlPtSize(funcIdx) - 1;
196 EXPECT_EQ(555, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
206 TEST_F(ParamFuncManipSplineDistTest, Initialization0FuncAllStatic)
214 vector<PFS> pf(3, PFS());
215 pf[0].ctrlPtsSize = 5;
216 pf[0].ctrlPtsArcRefIdx = 0;
217 pf[1].ctrlPtsSize = 5;
218 pf[1].ctrlPtsArcRefIdx = 0;
219 pf[2].ctrlPtsSize = 8;
220 pf[2].ctrlPtsArcRefIdx = 1;
224 pf[0].evalReq[(size_t)
FeM::INT1] =
false;
225 pf[0].evalReq[(size_t)
FeM::INT2] =
false;
228 pf[1].evalReq[(size_t)
FeM::INT1] =
false;
229 pf[1].evalReq[(size_t)
FeM::INT2] =
false;
232 pf[2].evalReq[(size_t)
FeM::INT1] =
false;
233 pf[2].evalReq[(size_t)
FeM::INT2] =
false;
237 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
239 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = 10 - 2 * j;
243 for (
size_t j = 0; j < funcs->funcCtrlPtSize(funcIdx); j++)
246 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 2 * j;
249 for (
size_t j = 1; j < funcs->funcCtrlPtSize(funcIdx); j++)
251 funcs->ctrlPtVal(funcIdx, j,
PfCpD::VAL) = -2 + 7 * j;
252 funcs->ctrlPtVal(funcIdx, j,
PfCpD::ARC) = 33 + 3 * j;
256 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 666;
257 funcs->ctrlPtVal(funcIdx, funcs->funcCtrlPtSize(funcIdx) - 1,
PfCpD::ARC) = 555;
259 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 123;
266 EXPECT_EQ(123, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
267 jj = funcs->funcCtrlPtSize(funcIdx) - 1;
268 EXPECT_EQ(555, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
271 EXPECT_EQ(123, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
272 jj = funcs->funcCtrlPtSize(funcIdx) - 1;
273 EXPECT_EQ(555, funcs->ctrlPtVal(funcIdx, jj,
PfCpD::ARC));
293 vector<PFS> pf(4, PFS());
294 pf[0].ctrlPtsSize = 4;
295 pf[0].ctrlPtsArcRefIdx = 0;
296 pf[1].ctrlPtsSize = 4;
297 pf[1].ctrlPtsArcRefIdx = 0;
298 pf[2].ctrlPtsSize = 7;
299 pf[2].ctrlPtsArcRefIdx = 1;
300 pf[3].ctrlPtsSize = 9;
301 pf[3].ctrlPtsArcRefIdx = 2;
305 pf[0].evalReq[(size_t)
FeM::INT1] =
false;
306 pf[0].evalReq[(size_t)
FeM::INT2] =
false;
311 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
313 funcs->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
315 funcs->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
317 funcs->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
328 void testValDiff(
ParamFuncsSPtr funcs,
double initT,
size_t funcIdx,
double funcShift)
331 EXPECT_DOUBLE_EQ(0 + funcShift, funcs->computeFuncVal(funcIdx));
333 EXPECT_DOUBLE_EQ(1 + funcShift, funcs->computeFuncVal(funcIdx));
334 funcs->setEvalArc(1.5 + initT,
EaG::NONE);
335 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
336 funcs->setEvalArc(2.0 - 1e-5 + initT,
EaG::NONE);
337 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
338 funcs->setEvalArc(2.0 + initT,
EaG::NONE);
339 EXPECT_DOUBLE_EQ(2.0 + funcShift, funcs->computeFuncVal(funcIdx));
340 funcs->setEvalArc(2.0 + 1e-5 + initT,
EaG::NONE);
341 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
342 funcs->setEvalArc(2.5 + initT,
EaG::NONE);
343 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
344 funcs->setEvalArc(3.5 + initT,
EaG::NONE);
345 EXPECT_DOUBLE_EQ(3 + funcShift, funcs->computeFuncVal(funcIdx));
349 EXPECT_DOUBLE_EQ(0 + funcShift, funcs->computeFuncVal(funcIdx));
351 EXPECT_DOUBLE_EQ(1 + funcShift, funcs->computeFuncVal(funcIdx));
353 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
355 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
357 EXPECT_DOUBLE_EQ(2.0 + funcShift, funcs->computeFuncVal(funcIdx));
359 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
361 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
363 EXPECT_DOUBLE_EQ(3 + funcShift, funcs->computeFuncVal(funcIdx));
367 EXPECT_DOUBLE_EQ(3 + funcShift, funcs->computeFuncVal(funcIdx));
369 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
371 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
373 EXPECT_DOUBLE_EQ(2.0 + funcShift, funcs->computeFuncVal(funcIdx));
375 EXPECT_DOUBLE_EQ(2.0 - 1e-5 + funcShift, funcs->computeFuncVal(funcIdx));
377 EXPECT_DOUBLE_EQ(1.5 + funcShift, funcs->computeFuncVal(funcIdx));
379 EXPECT_DOUBLE_EQ(1 + funcShift, funcs->computeFuncVal(funcIdx));
381 EXPECT_DOUBLE_EQ(0 + funcShift, funcs->computeFuncVal(funcIdx));
385 TEST_F(ParamFuncManipSplineDistTest, evalArcFuncValFuncValDiff1)
391 EvalArcFuncValFuncValDiff1::initValDiff(funcs, initT);
394 EvalArcFuncValFuncValDiff1::testValDiff(funcs, initT, funcIdx, funcShift = 0);
396 EvalArcFuncValFuncValDiff1::testValDiff(funcs, initT, funcIdx, funcShift = 1);
399 TEST_F(ParamFuncManipSplineDistTest, funcValInt1funcValInt2)
406 vector<PFS> pf(4, PFS());
407 pf[0].ctrlPtsSize = 4;
408 pf[0].ctrlPtsArcRefIdx = 0;
409 pf[1].ctrlPtsSize = 4;
410 pf[1].ctrlPtsArcRefIdx = 0;
411 pf[2].ctrlPtsSize = 7;
412 pf[2].ctrlPtsArcRefIdx = 1;
413 pf[3].ctrlPtsSize = 9;
414 pf[3].ctrlPtsArcRefIdx = 2;
422 funcs->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
424 funcs->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
426 funcs->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
428 funcs->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
433 EXPECT_DOUBLE_EQ(0, funcs->computeFuncInt1(0));
435 EXPECT_DOUBLE_EQ(0.5, funcs->computeFuncInt1(0));
436 funcs->setEvalArc(2.5 + initT,
EaG::NONE);
437 EXPECT_DOUBLE_EQ(2.875, funcs->computeFuncInt1(0));
438 funcs->setEvalArc(3.5 + initT,
EaG::NONE);
439 EXPECT_DOUBLE_EQ(4.5, funcs->computeFuncInt1(0));
440 funcs->setEvalArc(4.0 + initT,
EaG::NONE);
441 EXPECT_DOUBLE_EQ(6.5, funcs->computeFuncInt1(0));
444 EXPECT_DOUBLE_EQ(0, funcs->computeFuncInt2(0));
446 EXPECT_DOUBLE_EQ(1. / 6., funcs->computeFuncInt2(0));
447 funcs->setEvalArc(2.5 + initT,
EaG::NONE);
448 EXPECT_DOUBLE_EQ(1.5625, funcs->computeFuncInt2(0));
449 funcs->setEvalArc(3.5 + initT,
EaG::NONE);
450 EXPECT_DOUBLE_EQ(2.375, funcs->computeFuncInt2(0));
451 funcs->setEvalArc(4.0 + initT,
EaG::NONE);
452 EXPECT_DOUBLE_EQ(10. / 3., funcs->computeFuncInt2(0));
455 EXPECT_DOUBLE_EQ(1, funcs->computeFuncDiff1(0));
457 EXPECT_DOUBLE_EQ(1, funcs->computeFuncDiff1(0));
459 ParamFuncsExtType funcs2(dynamic_cast<ParamFuncsExtType &>(*funcs));
464 EXPECT_DOUBLE_EQ(0, funcs2.computeFuncInt1(0));
466 EXPECT_DOUBLE_EQ(0.5, funcs2.computeFuncInt1(0));
467 funcs2.setEvalArc(2.5 + initT,
EaG::NONE);
468 EXPECT_DOUBLE_EQ(2.875, funcs2.computeFuncInt1(0));
469 funcs2.setEvalArc(3.5 + initT,
EaG::NONE);
470 EXPECT_DOUBLE_EQ(4.5, funcs2.computeFuncInt1(0));
471 funcs2.setEvalArc(4.0 + initT,
EaG::NONE);
472 EXPECT_DOUBLE_EQ(6.5, funcs2.computeFuncInt1(0));
475 EXPECT_DOUBLE_EQ(0, funcs2.computeFuncInt2(0));
477 EXPECT_DOUBLE_EQ(1. / 6., funcs2.computeFuncInt2(0));
478 funcs2.setEvalArc(2.5 + initT,
EaG::NONE);
479 EXPECT_DOUBLE_EQ(1.5625, funcs2.computeFuncInt2(0));
480 funcs2.setEvalArc(3.5 + initT,
EaG::NONE);
481 EXPECT_DOUBLE_EQ(2.375, funcs2.computeFuncInt2(0));
482 funcs2.setEvalArc(4.0 + initT,
EaG::NONE);
483 EXPECT_DOUBLE_EQ(10. / 3., funcs2.computeFuncInt2(0));
486 EXPECT_DOUBLE_EQ(1, funcs2.computeFuncDiff1(0));
488 EXPECT_DOUBLE_EQ(1, funcs2.computeFuncDiff1(0));
490 ParamFuncsExtType funcs3;
491 funcs3 =
dynamic_cast<ParamFuncsExtType &
>(*funcs);
496 EXPECT_DOUBLE_EQ(0, funcs3.computeFuncInt1(0));
498 EXPECT_DOUBLE_EQ(0.5, funcs3.computeFuncInt1(0));
499 funcs3.setEvalArc(2.5 + initT,
EaG::NONE);
500 EXPECT_DOUBLE_EQ(2.875, funcs3.computeFuncInt1(0));
501 funcs3.setEvalArc(3.5 + initT,
EaG::NONE);
502 EXPECT_DOUBLE_EQ(4.5, funcs3.computeFuncInt1(0));
503 funcs3.setEvalArc(4.0 + initT,
EaG::NONE);
504 EXPECT_DOUBLE_EQ(6.5, funcs3.computeFuncInt1(0));
507 EXPECT_DOUBLE_EQ(0, funcs3.computeFuncInt2(0));
509 EXPECT_DOUBLE_EQ(1. / 6., funcs3.computeFuncInt2(0));
510 funcs3.setEvalArc(2.5 + initT,
EaG::NONE);
511 EXPECT_DOUBLE_EQ(1.5625, funcs3.computeFuncInt2(0));
512 funcs3.setEvalArc(3.5 + initT,
EaG::NONE);
513 EXPECT_DOUBLE_EQ(2.375, funcs3.computeFuncInt2(0));
514 funcs3.setEvalArc(4.0 + initT,
EaG::NONE);
515 EXPECT_DOUBLE_EQ(10. / 3., funcs3.computeFuncInt2(0));
518 EXPECT_DOUBLE_EQ(1, funcs3.computeFuncDiff1(0));
520 EXPECT_DOUBLE_EQ(1, funcs3.computeFuncDiff1(0));
525 using pfsd = ParamFuncsExtType;
526 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_A0)
528 double dt = 1, v = 1, av = 0, dsAnsGiven = 1;
530 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
531 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
532 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
533 EXPECT_DOUBLE_EQ(dt, dtAns);
535 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_A0)
537 double dt = 1, v = -1, av = 0, dsAnsGiven = 1;
539 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
540 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
541 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
542 EXPECT_DOUBLE_EQ(dt, dtAns);
544 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_A0)
546 double dt = -1, v = +1, av = 0, dsAnsGiven = -1;
548 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
549 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
550 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
551 EXPECT_DOUBLE_EQ(dt, dtAns);
553 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_A0)
555 double dt = -1, v = -1, av = 0, dsAnsGiven = -1;
557 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
558 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
559 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
560 EXPECT_DOUBLE_EQ(dt, dtAns);
563 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_APos)
565 double dt = 1, v = 1, av = 1, dsAnsGiven = 1.5;
567 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
568 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
569 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
570 EXPECT_DOUBLE_EQ(dt, dtAns);
572 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_ANeg)
574 double dt = 1, v = -1, av = -1, dsAnsGiven = 1.5;
576 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
577 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
578 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
579 EXPECT_DOUBLE_EQ(dt, dtAns);
581 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_APos)
583 double dt = -1, v = +1, av = +1, dsAnsGiven = -1.5;
585 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
586 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
587 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
588 EXPECT_DOUBLE_EQ(dt, dtAns);
590 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_ANeg)
592 double dt = -1, v = -1, av = -1, dsAnsGiven = -1.5;
594 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
595 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
596 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
597 EXPECT_DOUBLE_EQ(dt, dtAns);
600 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_ANeg_Above0)
602 double dt = 1, v = 1, av = -0.5, dsAnsGiven = 0.75;
604 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
605 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
606 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
607 EXPECT_DOUBLE_EQ(dt, dtAns);
609 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_APos_Below0)
611 double dt = 1, v = -1, av = 0.5, dsAnsGiven = 0.75;
613 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
614 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
615 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
616 EXPECT_DOUBLE_EQ(dt, dtAns);
618 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_ANeg_Above0)
620 double dt = -1, v = 1, av = -0.5, dsAnsGiven = -0.75;
622 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
623 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
624 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
625 EXPECT_DOUBLE_EQ(dt, dtAns);
627 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_APos_Below0)
629 double dt = -1, v = -1, av = 0.5, dsAnsGiven = -0.75;
631 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
632 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
633 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
634 EXPECT_DOUBLE_EQ(dt, dtAns);
637 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_ANeg_Below0_1)
639 double dt = 1, v = 1, av = -1.5, dsAnsGiven = 5. / 12.;
641 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
642 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
643 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
644 EXPECT_DOUBLE_EQ(dt, dtAns);
646 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_APos_Above0_1)
648 double dt = 1, v = -1, av = +1.5, dsAnsGiven = 5. / 12.;
650 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
651 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
652 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
653 EXPECT_DOUBLE_EQ(dt, dtAns);
655 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_ANeg_Below0_1)
657 double dt = -1, v = 1, av = -1.5, dsAnsGiven = -5. / 12.;
659 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
660 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
661 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
662 EXPECT_DOUBLE_EQ(dt, dtAns);
664 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_APos_Above0_1)
666 double dt = -1, v = -1, av = +1.5, dsAnsGiven = -5. / 12.;
668 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
669 EXPECT_DOUBLE_EQ(dsAnsGiven, dsAns);
670 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
671 EXPECT_DOUBLE_EQ(dt, dtAns);
674 TEST(Spline0computeDtDs_V_AV_Test, TPos_VPos_ANeg_Below0)
676 double dt = 6, v = 3, av = -3.5;
678 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
679 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
680 EXPECT_DOUBLE_EQ(dt, dtAns);
682 TEST(Spline0computeDtDs_V_AV_Test, TPos_VNeg_APos_Above0)
684 double dt = 6, v = -3, av = +3.5;
686 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
687 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
688 EXPECT_DOUBLE_EQ(dt, dtAns);
690 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VPos_ANeg_Below0)
692 double dt = -6, v = 3, av = -3.5;
694 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
695 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
696 EXPECT_DOUBLE_EQ(dt, dtAns);
698 TEST(Spline0computeDtDs_V_AV_Test, TNeg_VNeg_APos_Above0)
700 double dt = -6, v = -3, av = +3.5;
702 dsAns = pfsd::computeDeltaS_V_AV(dt, v, av);
703 dtAns = pfsd::computeDeltaT_V_AV(dsAns, v, av);
704 EXPECT_DOUBLE_EQ(dt, dtAns);
708 TEST_F(ParamFuncManipSplineDistTest, distTimeV)
710 ParamFuncsExtTypePtr funcss = dynamic_pointer_cast<ParamFuncsExtType>(funcs);
717 vector<PFS> pf(4, PFS());
718 pf[0].ctrlPtsSize = 4;
719 pf[0].ctrlPtsArcRefIdx = 0;
720 pf[1].ctrlPtsSize = 4;
721 pf[1].ctrlPtsArcRefIdx = 0;
722 pf[2].ctrlPtsSize = 7;
723 pf[2].ctrlPtsArcRefIdx = 1;
724 pf[3].ctrlPtsSize = 9;
725 pf[3].ctrlPtsArcRefIdx = 2;
730 vector<size_t> idxCfV(1, 0);
734 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -1;
735 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
736 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
737 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
738 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = -1;
739 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
740 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL) = -5;
741 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
742 funcss->precompute();
744 funcss->setEvalArc(1 + initT,
EaG::NONE);
745 EXPECT_DOUBLE_EQ(0.5, funcss->computeS());
746 EXPECT_DOUBLE_EQ(1 + initT, funcss->computeT(0.5));
747 funcss->setEvalArc(2 + initT,
EaG::NONE);
748 EXPECT_DOUBLE_EQ(1, funcss->computeS());
749 EXPECT_DOUBLE_EQ(2 + initT, funcss->computeT(1));
750 funcss->setEvalArc(3 + initT,
EaG::NONE);
751 EXPECT_DOUBLE_EQ(1.5, funcss->computeS());
752 EXPECT_DOUBLE_EQ(3 + initT, funcss->computeT(1.5));
753 funcss->setEvalArc(3.5 + initT,
EaG::NONE);
754 EXPECT_DOUBLE_EQ(2.5, funcss->computeS());
755 EXPECT_DOUBLE_EQ(3.5 + initT, funcss->computeT(2.5));
756 funcss->setEvalArc(4 + initT,
EaG::NONE);
757 EXPECT_DOUBLE_EQ(4.5, funcss->computeS());
758 EXPECT_DOUBLE_EQ(4 + initT, funcss->computeT(4.5));
760 funcss->setEvalArc(1 + initT,
EaG::NONE);
761 EXPECT_DOUBLE_EQ(0.5, funcss->computeS());
763 EXPECT_DOUBLE_EQ(1 + initT, funcss->computeT(0.5,
EaG::NEAR_LAST));
765 EXPECT_DOUBLE_EQ(3 + initT, funcss->computeT(1.5,
EaG::NEAR_LAST));
766 EXPECT_DOUBLE_EQ(3.5 + initT, funcss->computeT(2.5,
EaG::NEAR_LAST));
767 EXPECT_DOUBLE_EQ(4 + initT, funcss->computeT(4.5,
EaG::NEAR_LAST));
770 EXPECT_DOUBLE_EQ(1, funcss->computeS());
772 EXPECT_DOUBLE_EQ(1.5, funcss->computeS());
774 EXPECT_DOUBLE_EQ(2.5, funcss->computeS());
776 EXPECT_DOUBLE_EQ(4.5, funcss->computeS());
779 for (
size_t i = 0; i < 4; i++)
781 funcss->setEvalArc(1 + initT,
EaG::NONE);
782 evalTempSol = funcss->computeFuncVal(i);
784 EXPECT_DOUBLE_EQ(evalTempSol, funcss->computeFuncVal(i));
786 for (
size_t i = 0; i < 4; i++)
788 funcss->setEvalArc(2 + initT,
EaG::NONE);
789 evalTempSol = funcss->computeFuncVal(i);
791 EXPECT_DOUBLE_EQ(evalTempSol, funcss->computeFuncVal(i));
794 vector<double> sLattice(8, 0);
803 vector<double> tLattice(120, 0);
804 funcss->computeS2TLattice(sLattice, tLattice);
806 EXPECT_DOUBLE_EQ(6, tLattice.size());
808 EXPECT_DOUBLE_EQ(0 + initT, tLattice[0]);
809 EXPECT_DOUBLE_EQ(1 + initT, tLattice[1]);
810 EXPECT_DOUBLE_EQ(2 + initT, tLattice[2]);
811 EXPECT_DOUBLE_EQ(3 + initT, tLattice[3]);
812 EXPECT_DOUBLE_EQ(3.5 + initT, tLattice[4]);
813 EXPECT_DOUBLE_EQ(4 + initT, tLattice[5]);
820 funcss->computeS2TLattice(sLattice, tLattice);
822 EXPECT_DOUBLE_EQ(4, tLattice.size());
824 EXPECT_DOUBLE_EQ(0 + initT, tLattice[0]);
825 EXPECT_DOUBLE_EQ(1 + initT, tLattice[1]);
826 EXPECT_DOUBLE_EQ(2 + initT, tLattice[2]);
827 EXPECT_DOUBLE_EQ(4 + initT, tLattice[3]);
832 funcss->computeS2TLattice(sLattice, tLattice);
834 EXPECT_DOUBLE_EQ(2, tLattice.size());
836 EXPECT_DOUBLE_EQ(0 + initT, tLattice[0]);
837 EXPECT_DOUBLE_EQ(4 + initT, tLattice[1]);
840 TEST_F(ParamFuncManipSplineDistTest, timeShift)
842 ParamFuncsExtTypePtr funcss = dynamic_pointer_cast<ParamFuncsExtType>(funcs);
848 vector<PFS> pf(4, PFS());
849 pf[0].ctrlPtsSize = 4;
850 pf[0].ctrlPtsArcRefIdx = 0;
851 pf[1].ctrlPtsSize = 4;
852 pf[1].ctrlPtsArcRefIdx = 0;
853 pf[2].ctrlPtsSize = 3;
854 pf[2].ctrlPtsArcRefIdx = 1;
855 pf[3].ctrlPtsSize = 3;
856 pf[3].ctrlPtsArcRefIdx = 2;
861 vector<size_t> idxCfV(1, 0);
866 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -1;
867 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
868 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
869 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
870 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = 0;
871 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
872 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL) = -5;
873 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
875 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = 0;
876 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
877 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
878 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
879 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = -1;
880 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 3 + initT;
881 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL) = -5;
882 funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC) = 4 + initT;
884 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -10;
885 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
886 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 6;
887 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
888 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = 0;
889 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 4 + initT;
891 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL) = -1;
892 funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC) = 0 + initT;
893 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL) = 1;
894 funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC) = 2 + initT;
895 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL) = -1;
896 funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC) = 4 + initT;
897 funcss->precompute();
901 funcss->shiftStartCtrlPt(shift);
903 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
904 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
905 EXPECT_DOUBLE_EQ(1, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
906 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
907 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
908 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
909 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
910 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
913 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
914 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
915 EXPECT_DOUBLE_EQ(1, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
916 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
917 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
918 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
919 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
920 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
923 EXPECT_DOUBLE_EQ(-2, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
924 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
925 EXPECT_DOUBLE_EQ(6, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
926 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
927 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
928 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
931 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
932 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
933 EXPECT_DOUBLE_EQ(1, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
934 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
935 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
936 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
939 funcss->shiftStartCtrlPt(shift);
941 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
942 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
943 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
944 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
945 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
946 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
947 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
948 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
951 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
952 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
953 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
954 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
955 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
956 EXPECT_DOUBLE_EQ(fmax(3 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
957 EXPECT_DOUBLE_EQ(-5, funcss->ctrlPtVal(funcIdx, 3,
PfCpD::VAL));
958 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 3,
PfCpD::ARC));
961 EXPECT_DOUBLE_EQ(4.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
962 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
963 EXPECT_DOUBLE_EQ(4.5, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
964 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
965 EXPECT_DOUBLE_EQ(0, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
966 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
969 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::VAL));
970 EXPECT_DOUBLE_EQ(initT, funcss->ctrlPtVal(funcIdx, 0,
PfCpD::ARC));
971 EXPECT_DOUBLE_EQ(0.5, funcss->ctrlPtVal(funcIdx, 1,
PfCpD::VAL));
972 EXPECT_DOUBLE_EQ(fmax(2 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 1,
PfCpD::ARC));
973 EXPECT_DOUBLE_EQ(-1, funcss->ctrlPtVal(funcIdx, 2,
PfCpD::VAL));
974 EXPECT_DOUBLE_EQ(fmax(4 + initT - shift - 1, initT), funcss->ctrlPtVal(funcIdx, 2,
PfCpD::ARC));
1026 ::testing::InitGoogleTest(&argc, argv);
1027 return RUN_ALL_TESTS();
Containts parametric function initialization data.
TEST(TestStateMap, CopyAssignmentOperatorArray)
std::shared_ptr< ParamFuncs > ParamFuncsSPtr
control point arc parameter
Helper function needed to upgrade c++ 2011.
function second derivative
int main(int argc, char **argv)
agent base center linear velocity is parametric function
EvalArcGuarantee
Flags if any guarantees about evaluation arc relative to last evaluation arc are present.
CtrlPtDim
Control point variable dimension.
close to previous evaluation arc
FuncEvalMode
Required type of computation relative to the parametric function.
function first derivative