4 #include <MathConstants.h>
5 #include <maths/rigidmotion/RigidMotionException.h>
6 #include <maths/rigidmotion/RigidMotionEngine.h>
7 #include <maths/rigidmotion/RigidMotionR2Factory.h>
8 #include <maths/rigidmotion/RigidMotionR3Factory.h>
9 #include <scene/primitives/Triangle.h>
10 #include <scene/dynamic/DynMotionEngine.h>
11 #include <scene/dynamic/DynMotion.h>
12 #include <scene/dynamic/DynMovingObject.h>
18 using namespace rigidmotion;
20 namespace HeliosTests{
34 double const eps = 0.00001;
80 bool testPureRigidMotion();
85 bool testHeliosRigidMotion();
93 bool testPureIdentityR2();
98 bool testPureTranslationR2();
103 bool testPureReflectionR2();
108 bool testPureGlideReflectionR2();
113 bool testPureRotationR2();
118 bool testPureIdentityR3();
123 bool testPureTranslationR3();
128 bool testPureReflectionR3();
133 bool testPureGlideReflectionR3();
138 bool testPureRotationR3();
143 bool testPureHelicalR3();
148 bool testPureRotationalSymmetryR3();
191 bool RigidMotionTest::run(){
194 for(
size_t i = 0 ; i < 10 ; ++i){
195 R2X.at(i) = (((double)i)-2.5)*std::pow(-1.0, (
double)i);
198 for(
size_t i = 0 ; i < 15 ; ++i){
199 R3X.at(i) = (((double)i)-2.5)*std::pow(-1.0, (
double)i);
203 if(!testPureRigidMotion())
return false;
204 if(!testHeliosRigidMotion())
return false;
210 bool RigidMotionTest::testPureRigidMotion(){
212 if(!testPureIdentityR2())
return false;
213 if(!testPureTranslationR2())
return false;
214 if(!testPureReflectionR2())
return false;
215 if(!testPureGlideReflectionR2())
return false;
216 if(!testPureRotationR2())
return false;
219 if(!testPureIdentityR3())
return false;
220 if(!testPureTranslationR3())
return false;
221 if(!testPureReflectionR3())
return false;
222 if(!testPureGlideReflectionR3())
return false;
223 if(!testPureRotationR3())
return false;
224 if(!testPureHelicalR3())
return false;
225 if(!testPureRotationalSymmetryR3())
return false;
229 bool RigidMotionTest::testHeliosRigidMotion(){
231 vector<Primitive *> primitives;
232 Vertex v0(-1.0, -1.0, 0.0);
233 Vertex v1(1.0, -1.0, 0.0);
240 primitives.push_back(&tr0);
241 primitives.push_back(&tr1);
242 primitives.push_back(&tr2);
243 primitives.push_back(&tr3);
248 if(!testHeliosIdentityR3(dmo))
return false;
249 if(!testHeliosTranslationR3(dmo))
return false;
250 if(!testHeliosReflectionR3(dmo))
return false;
251 if(!testHeliosGlideReflectionR3(dmo))
return false;
252 if(!testHeliosRotationR3(dmo))
return false;
253 if(!testHeliosHelicalR3(dmo))
return false;
254 if(!testHeliosRotationalSymmetryR3(dmo))
return false;
261 bool RigidMotionTest::testPureIdentityR2(){
263 mat Y = rme.apply(f, R2X);
265 bool passed = !any(vectorise(Z) > eps);
266 if(!passed)
return passed;
268 passed = RigidMotion::SuperType::R2_BASE == f.
findSuperType();
269 if(!passed)
return passed;
271 if(!passed)
return passed;
272 passed = RigidMotion::Type::IDENTITY_R2 == f.
findType();
273 if(!passed)
return passed;
275 if(!passed)
return passed;
277 mat L = rme.computeFixedPoints(f, dim);
279 passed = !any(vectorise(abs(L-EL)) > eps);
280 if(!passed)
return passed;
284 bool RigidMotionTest::testPureTranslationR2(){
285 colvec shift(std::vector<double>({1.67, -2.27}));
287 mat Y = rme.apply(f, R2X);
288 mat EY = R2X.each_col() + shift;
290 bool passed = !any(vectorise(Z) > eps);
291 if(!passed)
return passed;
293 passed = RigidMotion::SuperType::R2_BASE == f.
findSuperType();
294 if(!passed)
return passed;
296 if(!passed)
return passed;
297 passed = RigidMotion::Type::TRANSLATION_R2 == f.
findType();
298 if(!passed)
return passed;
300 if(!passed)
return passed;
304 mat L = rme.computeFixedPoints(f, dim);
309 if(!passed)
return passed;
313 bool RigidMotionTest::testPureReflectionR2(){
314 colvec axis(std::vector<double>({2.1, -3.9}));
315 colvec X(std::vector<double>({-3, 1}));
317 colvec Y = rme.apply(f, X);
318 colvec EY(std::vector<double>({0.81651376, 3.05504587}));
319 bool passed = !any(vectorise(abs(Y-EY)) > eps);
320 if(!passed)
return passed;
322 passed = RigidMotion::SuperType::R2_REFLECTION == f.
findSuperType();
323 if(!passed)
return passed;
325 if(!passed)
return passed;
326 passed = RigidMotion::Type::REFLECTION_R2 == f.
findType();
327 if(!passed)
return passed;
329 if(!passed)
return passed;
331 mat L = rme.computeFixedPoints(f, dim);
332 if(L(0,0) < 0.0) L = -L;
333 mat EL(
"0.47409982; -0.8804711");
334 passed = !any(vectorise(abs(L-EL)) > eps);
335 if(!passed)
return passed;
337 mat Y2 = rme.apply(f, R2X);
339 EY2.at(0, 0) = 0.12385321; EY2.at(1, 0) = 2.91284404;
340 EY2.at(0, 1) = 0.69266055; EY2.at(1, 1) = 0.14220183;
341 EY2.at(0, 2) = 1.26146789; EY2.at(1, 2) = -2.62844037;
342 EY2.at(0, 3) = 1.83027523; EY2.at(1, 3) = -5.39908257;
343 EY2.at(0, 4) = 2.39908257; EY2.at(1, 4) = -8.16972477;
345 passed = !any(vectorise(Z) > eps);
346 if(!passed)
return passed;
348 axis = std::vector<double>({2.1, 0.9});
349 f = rm2f.makeReflection(axis);
350 mat Y3 = rme.apply(f, R2X);
352 EY3.at(0, 0) = -0.63793103; EY3.at(1, 0) = -2.84482759;
353 EY3.at(0, 1) = -0.70689655; EY3.at(1, 1) = -0.01724138;
354 EY3.at(0, 2) = -0.77586207; EY3.at(1, 2) = 2.81034483;
355 EY3.at(0, 3) = -0.84482759; EY3.at(1, 3) = 5.63793103;
356 EY3.at(0, 4) = -0.9137931; EY3.at(1, 4) = 8.46551724;
358 passed = !any(vectorise(Z) > eps);
359 if(!passed)
return passed;
363 bool RigidMotionTest::testPureGlideReflectionR2(){
364 colvec axis(std::vector<double>({2.1, 1.9}));
366 mat Y = rme.apply(f, R2X);
368 EY.at(0, 0) = 2.7262137; EY.at(1, 0) = -1.29533046;
369 EY.at(0, 1) = 0.93569001; EY.at(1, 1) = 0.89419573;
370 EY.at(0, 2) = -0.85483368; EY.at(1, 2) = 3.08372191;
371 EY.at(0, 3) = -2.64535737; EY.at(1, 3) = 5.27324809;
372 EY.at(0, 4) = -4.43588106; EY.at(1, 4) = 7.46277428;
374 bool passed = !any(vectorise(Z) > eps);
375 if(!passed)
return passed;
377 passed = RigidMotion::SuperType::R2_REFLECTION == f.
findSuperType();
378 if(!passed)
return passed;
380 if(!passed)
return passed;
381 passed = RigidMotion::Type::GLIDE_REFLECTION_R2 == f.
findType();
382 if(!passed)
return passed;
384 if(!passed)
return passed;
386 mat L = rme.computeAssociatedInvariant(f, dim);
387 if(L(0, 0) < 0) L = -L;
388 mat EL(
"0.74153578; 0.67091332");
389 passed = !any(vectorise(abs(L-EL)) > eps);
390 if(!passed)
return passed;
392 f = rm2f.makeTranslation(2*axis/norm(axis));
395 mat Y2 = rme.apply(h, R2X);
397 passed = !any(vectorise(Z) > eps);
398 if(!passed)
return passed;
403 bool RigidMotionTest::testPureRotationR2(){
404 colvec center = R2X.col(2);
405 RigidMotion f = rm2f.makeRotation(-M_PI/3, center);
406 mat Y = rme.apply(f, R2X);
408 EY.at(0, 0) = 2.96410162; EY.at(1, 0) = 2.96410162;
409 EY.at(0, 1) = 2.23205081; EY.at(1, 1) = 0.23205081;
410 EY.at(0, 2) = 1.5; EY.at(1, 2) = -2.5;
411 EY.at(0, 3) = 0.76794919; EY.at(1, 3) = -5.23205081;
412 EY.at(0, 4) = 0.03589838; EY.at(1, 4) = -7.96410162;
414 bool passed = !any(vectorise(Z) > eps);
415 if(!passed)
return passed;
417 passed = RigidMotion::SuperType::R2_ROTATION == f.
findSuperType();
418 if(!passed)
return passed;
420 if(!passed)
return passed;
421 passed = RigidMotion::Type::ROTATION_R2 == f.
findType();
422 if(!passed)
return passed;
424 if(!passed)
return passed;
426 mat L = rme.computeFixedPoints(f, dim);
428 passed = !any(vectorise(abs(L-EL)) > eps);
429 if(!passed)
return passed;
434 bool RigidMotionTest::testPureIdentityR3(){
436 mat Y = rme.apply(f, R3X);
438 bool passed = !any(vectorise(Z) > eps);
439 if(!passed)
return passed;
441 passed = RigidMotion::SuperType::R3_BASE == f.
findSuperType();
442 if(!passed)
return passed;
444 if(!passed)
return passed;
445 passed = RigidMotion::Type::IDENTITY_R3 == f.
findType();
446 if(!passed)
return passed;
448 if(!passed)
return passed;
450 mat L = rme.computeFixedPoints(f, dim);
456 passed = !any(vectorise(L-EL) > eps);
457 if(!passed)
return passed;
462 bool RigidMotionTest::testPureTranslationR3(){
463 colvec shift(std::vector<double>({1.1, -3.39, 0.24}));
465 mat Y = rme.apply(f, R3X);
466 mat EY = R3X.each_col() + shift;
468 bool passed = !any(vectorise(Z) > eps);
469 if(!passed)
return passed;
471 passed = RigidMotion::SuperType::R3_BASE == f.
findSuperType();
472 if(!passed)
return passed;
474 if(!passed)
return passed;
475 passed = RigidMotion::Type::TRANSLATION_R3 == f.
findType();
476 if(!passed)
return passed;
478 if(!passed)
return passed;
483 bool RigidMotionTest::testPureReflectionR3(){
484 colvec ortho(std::vector<double>({1.0, 0.5, 0.3}));
486 mat Y = rme.apply(f, R3X);
488 "0.3358209 0.24626866 -0.82835821 1.41044776 -1.99253731; "
489 "2.91791045 1.87313433 -6.6641791 11.45522388 -16.24626866; "
490 "0.35074627 -2.2761194 4.20149254 -6.12686567 8.05223881"
493 bool passed = !any(vectorise(Z) > eps);
494 if(!passed)
return passed;
497 passed = !any(vectorise(Z) > eps);
498 if(!passed)
return passed;
500 passed = RigidMotion::SuperType::R3_REFLECTION == f.
findSuperType();
501 if(!passed)
return passed;
503 if(!passed)
return passed;
504 passed = RigidMotion::Type::REFLECTION_R3 == f.
findType();
505 if(!passed)
return passed;
507 if(!passed)
return passed;
509 mat L = rme.computeFixedPoints(f, dim);
510 if(L(0,0) < 0) L = -L;
511 mat EL(
"0.86386843; 0.43193421; 0.25916053");
512 passed = !any(vectorise(abs(L-EL)) > eps);
513 if(!passed)
return passed;
515 f = rm3f.makeReflectionX();
516 Y = rme.apply(f, R3X);
518 "2.5 0.5 -3.5 6.5 -9.5;"
519 "1.5 1.5 -4.5 7.5 -10.5;"
520 "-0.5 -2.5 5.5 -8.5 11.5"
523 passed = !any(vectorise(Z) > eps);
524 if(!passed)
return passed;
525 f = rm3f.makeReflection(colvec(std::vector<double>({1.0, 0.0, 0.0})));
526 Y = rme.apply(f, R3X);
528 passed = !any(vectorise(Z) > eps);
529 if(!passed)
return passed;
531 f = rm3f.makeReflectionY();
532 Y = rme.apply(f, R3X);
534 "-2.5 -0.5 3.5 -6.5 9.5;"
535 "-1.5 -1.5 4.5 -7.5 10.5;"
536 "-0.5 -2.5 5.5 -8.5 11.5"
539 passed = !any(vectorise(Z) > eps);
540 if(!passed)
return passed;
541 f = rm3f.makeReflection(colvec(std::vector<double>({0.0, 1.0, 0.0})));
542 Y = rme.apply(f, R3X);
544 passed = !any(vectorise(Z) > eps);
545 if(!passed)
return passed;
547 f = rm3f.makeReflectionY();
548 Y = rme.apply(f, R3X);
550 "-2.5 -0.5 3.5 -6.5 9.5;"
551 "-1.5 -1.5 4.5 -7.5 10.5;"
552 "-0.5 -2.5 5.5 -8.5 11.5"
555 passed = !any(vectorise(Z) > eps);
556 if(!passed)
return passed;
557 f = rm3f.makeReflection(colvec(std::vector<double>({0.0, 1.0, 0.0})));
558 Y = rme.apply(f, R3X);
560 passed = !any(vectorise(Z) > eps);
561 if(!passed)
return passed;
563 f = rm3f.makeReflectionZ();
564 Y = rme.apply(f, R3X);
566 "-2.5 -0.5 3.5 -6.5 9.5;"
567 "1.5 1.5 -4.5 7.5 -10.5;"
568 "0.5 2.5 -5.5 8.5 -11.5;"
571 passed = !any(vectorise(Z) > eps);
572 if(!passed)
return passed;
573 f = rm3f.makeReflection(colvec(std::vector<double>({0.0, 0.0, 1.0})));
574 Y = rme.apply(f, R3X);
576 passed = !any(vectorise(Z) > eps);
577 if(!passed)
return passed;
579 f = rm3f.makeReflectionX();
582 g = rm3f.makeReflectionZ();
584 Y = rme.apply(f, R3X);
586 "2.5 0.5 -3.5 6.5 -9.5;"
587 "-1.5 -1.5 4.5 -7.5 10.5;"
588 "0.5 2.5 -5.5 8.5 -11.5;"
591 passed = !any(vectorise(Z) > eps);
592 if(!passed)
return passed;
597 bool RigidMotionTest::testPureGlideReflectionR3(){
598 colvec ortho(std::vector<double>({1.0, 0.5, 0.3}));
599 colvec shift(std::vector<double>({-4.0/5.0, 1, 1}));
600 RigidMotion f = rm3f.makeGlideReflection(ortho, shift);
601 mat Y = rme.apply(f, R3X);
603 "-0.4641791 -0.55373134 -1.62835821 0.61044776 -2.79253731;"
604 "3.91791045 2.87313433 -5.6641791 12.45522388 -15.24626866;"
605 "1.35074627 -1.2761194 5.20149254 -5.12686567 9.05223881"
608 bool passed = !any(vectorise(Z) > eps);
609 if(!passed)
return passed;
611 passed = RigidMotion::SuperType::R3_REFLECTION == f.
findSuperType();
612 if(!passed)
return passed;
614 if(!passed)
return passed;
615 passed = RigidMotion::Type::GLIDE_REFLECTION_R3 == f.
findType();
616 if(!passed)
return passed;
618 if(!passed)
return passed;
620 mat L = rme.computeAssociatedInvariant(f, dim);
621 if(L(0, 0) < 0) L = -L;
622 mat EL(
"0.86386843; 0.43193421; 0.25916053");
623 passed = !any(vectorise(abs(L-EL)) > eps);
624 if(!passed)
return passed;
626 f = rm3f.makeGlideReflection(ortho, -shift);
629 passed = !any(vectorise(Z) > eps);
630 if(!passed)
return passed;
634 f = rm3f.makeGlideReflection(ortho, colvec(
"1 1 1"));
643 bool RigidMotionTest::testPureRotationR3(){
644 colvec axis(std::vector<double>({0.4, 0.2, 1.0}));
647 mat Y = rme.apply(f, R3X);
649 "1.4704453 0.92147891 -3.31340313 5.70532734 -8.09725156;"
650 "1.49407244 -1.24669143 0.99931042 -0.75192941 0.5045484;"
651 "-2.08699261 -2.51925328 7.12549917 -11.73174506 16.33799094"
654 bool passed = !any(vectorise(Z) > eps);
655 if(!passed)
return passed;
657 passed = RigidMotion::SuperType::R3_ROTATION == f.
findSuperType();
658 if(!passed)
return passed;
660 if(!passed)
return passed;
661 passed = RigidMotion::Type::ROTATION_R3 == f.
findType();
662 if(!passed)
return passed;
664 if(!passed)
return passed;
666 mat L = rme.computeFixedPoints(f, dim);
667 if(L(0, 0) < 0) L = -L;
668 mat EL(
"0.36514837; 0.18257419; 0.91287093");
669 passed = !any(vectorise(abs(L-EL)) > eps);
670 if(!passed)
return passed;
672 f = rm3f.makeRotation(axis, -theta);
675 passed = !any(vectorise(Z) > eps);
676 if(!passed)
return passed;
678 f = rm3f.makeRotationX(theta);
679 Y = rme.apply(f, R3X);
681 "-2.5 -0.5 3.5 -6.5 9.5;"
682 "-0.80495876 -2.76001899 6.32499674 -9.8899745 13.45495225;"
683 "-1.36089728 -0.93930568 3.23950863 -5.53971159 7.83991454"
686 passed = !any(vectorise(Z) > eps);
687 if(!passed)
return passed;
689 f = rm3f.makeRotationY(theta);
690 Y = rme.apply(f, R3X);
692 "1.01575456 2.54922319 -6.11420095 9.6791787 -13.24415645;"
693 "1.5 1.5 -4.5 7.5 -10.5;"
694 "-2.33842739 0.03822444 2.26197851 -4.56218147 6.86238442"
697 passed = !any(vectorise(Z) > eps);
698 if(!passed)
return passed;
700 f = rm3f.makeRotationZ(theta);
701 Y = rme.apply(f, R3X);
703 "1.99328468 1.57169308 -5.13667083 8.70164858 -12.26662633;"
704 "2.1276316 0.17257136 -2.47277431 4.77297727 -7.07318022;"
705 "-0.5 -2.5 5.5 -8.5 11.5"
708 passed = !any(vectorise(Z) > eps);
709 if(!passed)
return passed;
714 bool RigidMotionTest::testPureHelicalR3(){
715 colvec axis(std::vector<double>({0.4, 0.2, 1.0}));
718 RigidMotion f = rm3f.makeHelical(axis, theta, glide);
719 mat Y = rme.apply(f, R3X);
721 "3.29618716 2.74722077 -1.48766127 7.5310692 -6.2715097;"
722 "2.40694337 -0.3338205 1.91218135 0.16094152 1.41741933;"
723 "2.47736204 2.04510137 11.68985381 -7.16739041 20.90234559"
726 bool passed = !any(vectorise(Z) > eps);
727 if(!passed)
return passed;
729 passed = RigidMotion::SuperType::R3_ROTATION == f.
findSuperType();
730 if(!passed)
return passed;
732 if(!passed)
return passed;
733 passed = RigidMotion::Type::HELICAL_R3 == f.
findType();
734 if(!passed)
return passed;
736 if(!passed)
return passed;
738 mat L = rme.computeAssociatedInvariant(f, dim);
739 if(L(0, 0) < 0) L = -L;
740 mat EL(
"0.36514837; 0.18257419; 0.91287093");
741 passed = !any(vectorise(abs(L-EL)) > eps);
742 if(!passed)
return passed;
744 f = rm3f.makeHelical(axis, -theta, -glide);
747 passed = !any(vectorise(Z) > eps);
748 if(!passed)
return passed;
750 f = rm3f.makeHelicalX(theta, glide);
751 Y = rme.apply(f, R3X);
753 "2.5 4.5 8.5 -1.5 14.5;"
754 "-0.80495876 -2.76001899 6.32499674 -9.8899745 13.45495225;"
755 "-1.36089728 -0.93930568 3.23950863 -5.53971159 7.83991454"
758 passed = !any(vectorise(Z) > eps);
759 if(!passed)
return passed;
761 f = rm3f.makeHelicalY(theta, glide);
762 Y = rme.apply(f, R3X);
764 "1.01575456 2.54922319 -6.11420095 9.6791787 -13.24415645;"
765 "6.5 6.5 0.5 12.5 -5.5;"
766 "-2.33842739 0.03822444 2.26197851 -4.56218147 6.86238442"
769 passed = !any(vectorise(Z) > eps);
770 if(!passed)
return passed;
772 f = rm3f.makeHelicalZ(theta, glide);
773 Y = rme.apply(f, R3X);
775 "1.99328468 1.57169308 -5.13667083 8.70164858 -12.26662633;"
776 "2.1276316 0.17257136 -2.47277431 4.77297727 -7.07318022;"
777 "4.5 2.5 10.5 -3.5 16.5"
781 passed = !any(vectorise(Z) > eps);
782 if(!passed)
return passed;
787 bool RigidMotionTest::testPureRotationalSymmetryR3(){
788 colvec axis(std::vector<double>({1.0, 0.5, 0.3}));
790 RigidMotion f = rm3f.makeRotationalSymmetry(axis, theta);
791 mat Y = rme.apply(f, R3X);
793 "2.23713056 1.83545467 -5.90803989 9.98062512 -14.05321035;"
794 "0.45443109 -2.15342901 3.85242692 -5.55142484 7.25042276;"
795 "-1.8811537 -0.8624672 3.6060881 -6.349709 9.0933299"
798 bool passed = !any(vectorise(Z) > eps);
799 if(!passed)
return passed;
800 f = rm3f.makeRotationalSymmetry(axis, -theta);
803 passed = !any(vectorise(Z) > eps);
804 if(!passed)
return passed;
806 passed = RigidMotion::SuperType::R3_ROTATIONAL_SYMMETRY==f.
findSuperType();
807 if(!passed)
return passed;
809 if(!passed)
return passed;
810 passed = RigidMotion::Type::ROTATIONAL_SYMMETRY_R3 == f.
findType();
811 if(!passed)
return passed;
813 if(!passed)
return passed;
815 mat L = rme.computeFixedPoints(f, dim);
817 passed = !any(vectorise(abs(L-EL)) > eps);
818 if(!passed)
return passed;
820 f = rm3f.makeRotationalSymmetryX(theta);
821 Y = rme.apply(f, R3X);
823 "2.5 0.5 -3.5 6.5 -9.5;"
824 "-0.80495876 -2.76001899 6.32499674 -9.8899745 13.45495225;"
825 "-1.36089728 -0.93930568 3.23950863 -5.53971159 7.83991454"
828 passed = !any(vectorise(Z) > eps);
829 if(!passed)
return passed;
831 f = rm3f.makeRotationalSymmetryY(theta);
832 Y = rme.apply(f, R3X);
834 "1.01575456 2.54922319 -6.11420095 9.6791787 -13.24415645;"
835 "-1.5 -1.5 4.5 -7.5 10.5;"
836 "-2.33842739 0.03822444 2.26197851 -4.56218147 6.86238442"
839 passed = !any(vectorise(Z) > eps);
840 if(!passed)
return passed;
842 f = rm3f.makeRotationalSymmetryZ(theta);
843 Y = rme.apply(f, R3X);
845 "1.99328468 1.57169308 -5.13667083 8.70164858 -12.26662633;"
846 "2.1276316 0.17257136 -2.47277431 4.77297727 -7.07318022;"
847 "0.5 2.5 -5.5 8.5 -11.5"
850 passed = !any(vectorise(Z) > eps);
851 if(!passed)
return passed;
853 f = rm3f.makeRotationalSymmetry(axis, theta, colvec(
"1;1;-1"));
854 Y = rme.apply(f, R3X);
856 "3.47911047 3.07743457 -4.66605999 11.22260503 -12.81123044;"
857 "3.11639653 0.50853643 6.51439236 -2.8894594 9.91238819;"
858 "-2.45769578 -1.43900929 3.02954602 -6.92625109 8.51678782"
861 passed = !any(vectorise(Z) > eps);
862 if(!passed)
return passed;
863 f = rm3f.makeRotationalSymmetry(axis, theta);
864 RigidMotion g = rm3f.makeTranslation(colvec(
"-1;-1;1"));
865 RigidMotion h = rm3f.makeTranslation(colvec(
"1;1;-1"));
868 mat Y2 = rme.apply(f, R3X);
869 Z = abs(Y2-EY) + abs(Y-EY);
870 passed = !any(vectorise(Z) > eps);
871 if(!passed)
return passed;
872 L = rme.computeFixedPoints(f, dim);
873 passed = !any(vectorise(abs(L-colvec(
"1;1;-1"))) > eps);
874 if(!passed)
return passed;
888 arma::mat dmeY = dme.apply(dm, X, dynObj);
889 arma::mat rmeY = rme.apply(
static_cast<RigidMotion>(dm), X);
895 size_t const m = dmeY.n_elem;
896 size_t const n = rmeY.n_elem;
897 if(m!=n)
return false;
898 for(
size_t i = 0 ; i < m ; ++i)
899 if(std::fabs(dmeY[i]-rmeY[i]) > eps)
return false;
906 RigidMotion tr = rm3f.makeTranslation(arma::colvec(
"-0.1;0.1;0"));
908 arma::mat dmeY = dme.apply(dm, X, dynObj);
909 arma::mat rmeY = rme.apply(
static_cast<RigidMotion>(dm), X);
915 size_t const m = dmeY.n_elem;
916 size_t const n = rmeY.n_elem;
917 if(m!=n)
return false;
918 for(
size_t i = 0 ; i < m ; ++i)
919 if(std::fabs(dmeY[i]-rmeY[i]) > eps)
return false;
928 rm3f.makeTranslation(O),
929 rme.compose(rm3f.makeReflectionZ(), rm3f.makeTranslation(-O))
931 DynMotion dm(rm3f.makeReflectionZ(),
true);
932 arma::mat dmeY = dme.apply(dm, X, dynObj);
933 arma::mat rmeY = rme.apply(rf, X);
939 size_t const m = dmeY.n_elem;
940 size_t const n = rmeY.n_elem;
941 if(m!=n)
return false;
942 for(
size_t i = 0 ; i < m ; ++i)
943 if(std::fabs(dmeY[i]-rmeY[i]) > eps)
return false;
952 rm3f.makeTranslation(O),
954 rm3f.makeGlideReflection(
955 arma::colvec(
"0;0;1"),
956 arma::colvec(
"0.5;0.5;0")
958 rm3f.makeTranslation(-O)
962 rm3f.makeGlideReflection(
963 arma::colvec(
"0;0;1"),
964 arma::colvec(
"0.5;0.5;0")
968 arma::mat dmeY = dme.apply(dm, X, dynObj);
969 arma::mat rmeY = rme.apply(rf, X);
975 size_t const m = dmeY.n_elem;
976 size_t const n = rmeY.n_elem;
977 if(m!=n)
return false;
978 for(
size_t i = 0 ; i < m ; ++i)
979 if(std::fabs(dmeY[i]-rmeY[i]) > eps)
return false;
988 rm3f.makeTranslation(O),
989 rme.compose(rm3f.makeRotationZ(0.67), rm3f.makeTranslation(-O))
991 DynMotion dm(rm3f.makeRotationZ(0.67),
true);
992 arma::mat dmeY = dme.apply(dm, X, dynObj);
993 arma::mat rmeY = rme.apply(rot, X);
999 size_t const m = dmeY.n_elem;
1000 size_t const n = rmeY.n_elem;
1001 if(m!=n)
return false;
1002 for(
size_t i = 0 ; i < m ; ++i)
1003 if(std::fabs(dmeY[i]-rmeY[i]) > eps)
return false;
1012 rm3f.makeTranslation(O),
1013 rme.compose(rm3f.makeHelicalZ(0.5, 1.0), rm3f.makeTranslation(-O))
1015 DynMotion dm(rm3f.makeHelicalZ(0.5, 1.0),
true);
1016 arma::mat dmeY = dme.apply(dm, X, dynObj);
1017 arma::mat rmeY = rme.apply(hm, X);
1023 size_t const m = dmeY.n_elem;
1024 size_t const n = rmeY.n_elem;
1025 if(m!=n)
return false;
1026 for(
size_t i = 0 ; i < m ; ++i)
1027 if(std::fabs(dmeY[i]-rmeY[i]) > eps)
return false;
1030 bool RigidMotionTest::testHeliosRotationalSymmetryR3(
1038 rm3f.makeTranslation(O),
1040 rm3f.makeRotationalSymmetryZ(0.34),
1041 rm3f.makeTranslation(-O)
1044 DynMotion dm(rm3f.makeRotationalSymmetryZ(0.34),
true);
1045 arma::mat dmeY = dme.apply(dm, X, dynObj);
1046 arma::mat rmeY = rme.apply(rs, X);
1052 size_t const m = dmeY.n_elem;
1053 size_t const n = rmeY.n_elem;
1054 if(m!=n)
return false;
1055 for(
size_t i = 0 ; i < m ; ++i)
1056 if(std::fabs(dmeY[i]-rmeY[i]) > eps)
return false;
Adapter which wraps a rigid motion engine to make it fit the dynamic Helios context.
Definition: DynMotionEngine.h:23
Class which wraps the RigidMotion class to implement extra features such as the self mode control mec...
Definition: DynMotion.h:26
Implementation of a dynamic object which supports dynamic motions (extended rigid motions)
Definition: DynMovingObject.h:39
arma::mat positionMatrixFromPrimitives() const
Obtain the position matrix for primitives defining the dynamic object.
Definition: DynObject.cpp:65
BaseTest class.
Definition: BaseTest.h:20
Rigid motion test.
Definition: RigidMotionTest.h:27
mat R3X
Matrix of points in R3 to be used by tests.
Definition: RigidMotionTest.h:54
RigidMotionR3Factory rm3f
The R3 rigid motion factory to be used by tests.
Definition: RigidMotionTest.h:46
RigidMotionR2Factory rm2f
The R2 rigid motion factory to be used by tests.
Definition: RigidMotionTest.h:42
mat R2X
Matrix of points in R2 to be used by tests.
Definition: RigidMotionTest.h:50
RigidMotionEngine rme
The rigid motion engine to be used by tests.
Definition: RigidMotionTest.h:38
DynMotionEngine dme
The dynamic motion engine to be used by helios tests.
Definition: RigidMotionTest.h:58
RigidMotionTest()
Rigid motion test constructor.
Definition: RigidMotionTest.h:65
Abstract class defining the common behavior for all primitives.
Definition: Primitive.h:24
void computeCentroid(bool const computeBound=false)
Compute the default centroid for the scene part as the midrange point and its boundaries too.
Definition: ScenePart.cpp:199
arma::colvec getCentroid() const
Obtain the centroid of the scene part.
Definition: ScenePart.h:289
std::vector< Primitive * > const & getPrimitives() const
Obtain the primitives of the scene part.
Definition: ScenePart.h:275
Class representing triangle primitive.
Definition: Triangle.h:13
Class representing a vertex.
Definition: Vertex.h:14
Class to handle operations with rigid motions.
Definition: RigidMotionEngine.h:19
Base class for rigid motion exceptions.
Definition: RigidMotionException.h:16
Class providing building methods for rigid motions in .
Definition: RigidMotionR2Factory.h:22
Class providing building methods for rigid motions in .
Definition: RigidMotionR3Factory.h:22
Interface that must be implemented by any class which represents a specific rigid motions.
Definition: RigidMotion.h:49
virtual Type findType() const
Obtain the type of the rigid motion.
Definition: RigidMotion.cpp:68
virtual SuperType findSuperType() const
Obtain the supertype of the rigid motion.
Definition: RigidMotion.cpp:22
virtual bool hasFixedPoints() const
Check if rigid motion has fixed points.
Definition: RigidMotion.cpp:61
virtual RigidMotion compose(RigidMotion const rm) const
Compose this rigid motion with given rigid motion so is obtained.
Definition: RigidMotion.cpp:11
virtual size_t findInvariantDimensionality() const
Obtain the dimensionality of the associated invariant which can be either the set of fixed points or ...
Definition: RigidMotion.cpp:105