- Timestamp:
- Sep 12, 2016, 2:03:15 PM (9 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- b67d89
- Parents:
- b3c052
- git-author:
- Frederik Heber <heber@…> (06/05/14 17:58:13)
- git-committer:
- Frederik Heber <heber@…> (09/12/16 14:03:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
rb3c052 r158ecb 74 74 ASSERT_DO(Assert::Throw); 75 75 76 setVerbosity( 5);76 setVerbosity(6); 77 77 } 78 78 … … 190 190 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 191 191 } 192 193 // test with two points, matching trivially 194 { 195 SphericalPointDistribution::Polygon_t polygon; 196 polygon += Vector(1.,0.,0.), Vector(-0.5, sqrt(3)*0.5,0.); 197 SphericalPointDistribution::Polygon_t newpolygon = 198 SPD.get<3>(); 199 SphericalPointDistribution::Polygon_t expected = newpolygon; 200 expected.pop_front(); // remove first point 201 expected.pop_front(); // remove second point 202 SphericalPointDistribution::Polygon_t remaining = 203 SphericalPointDistribution::matchSphericalPointDistributions( 204 polygon, 205 newpolygon); 206 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 207 } 208 209 // test with two points, full rotation 210 { 211 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 212 SphericalPointDistribution::Polygon_t polygon; 213 polygon += 214 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 215 RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI); 216 SphericalPointDistribution::Polygon_t newpolygon = 217 SPD.get<3>(); 218 SphericalPointDistribution::Polygon_t expected = newpolygon; 219 expected.pop_front(); // remove first point 220 expected.pop_front(); // remove second point 221 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 222 iter != expected.end(); ++iter) 223 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 224 SphericalPointDistribution::Polygon_t remaining = 225 SphericalPointDistribution::matchSphericalPointDistributions( 226 polygon, 227 newpolygon); 228 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 229 } 230 231 // test with three points, matching trivially 232 { 233 SphericalPointDistribution::Polygon_t polygon; 234 polygon += Vector(1.,0.,0.), Vector(-0.5, sqrt(3)*0.5,0.), Vector(-0.5, -sqrt(3)*0.5,0.); 235 SphericalPointDistribution::Polygon_t newpolygon = 236 SPD.get<3>(); 237 SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant 238 SphericalPointDistribution::Polygon_t remaining = 239 SphericalPointDistribution::matchSphericalPointDistributions( 240 polygon, 241 newpolygon); 242 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 243 } 244 245 246 // test with three points, full rotation 247 { 248 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 249 SphericalPointDistribution::Polygon_t polygon; 250 polygon += 251 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 252 RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI), 253 RotationAxis.rotateVector(Vector(-0.5, -sqrt(3)*0.5,0.), 47.6/180*M_PI); 254 SphericalPointDistribution::Polygon_t newpolygon = 255 SPD.get<3>(); 256 SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant 257 SphericalPointDistribution::Polygon_t remaining = 258 SphericalPointDistribution::matchSphericalPointDistributions( 259 polygon, 260 newpolygon); 261 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 262 } 192 263 } 193 264 … … 232 303 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 233 304 } 305 306 // test with two points, matching trivially 307 { 308 SphericalPointDistribution::Polygon_t polygon; 309 polygon += Vector(1.,0.,0.), Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.); 310 SphericalPointDistribution::Polygon_t newpolygon = 311 SPD.get<4>(); 312 SphericalPointDistribution::Polygon_t expected = newpolygon; 313 expected.pop_front(); // remove first point 314 expected.pop_front(); // remove second point 315 SphericalPointDistribution::Polygon_t remaining = 316 SphericalPointDistribution::matchSphericalPointDistributions( 317 polygon, 318 newpolygon); 319 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 320 } 321 322 // test with two points, full rotation 323 { 324 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 325 SphericalPointDistribution::Polygon_t polygon; 326 polygon += 327 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 328 RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI); 329 SphericalPointDistribution::Polygon_t newpolygon = 330 SPD.get<4>(); 331 SphericalPointDistribution::Polygon_t expected = newpolygon; 332 expected.pop_front(); // remove first point 333 expected.pop_front(); // remove second point 334 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 335 iter != expected.end(); ++iter) 336 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 337 SphericalPointDistribution::Polygon_t remaining = 338 SphericalPointDistribution::matchSphericalPointDistributions( 339 polygon, 340 newpolygon); 341 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 342 } 343 344 // test with three points, matching trivially 345 { 346 SphericalPointDistribution::Polygon_t polygon; 347 polygon += 348 Vector(1.,0.,0.), 349 Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 350 Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)); 351 SphericalPointDistribution::Polygon_t newpolygon = 352 SPD.get<4>(); 353 SphericalPointDistribution::Polygon_t expected = newpolygon; 354 expected.pop_front(); // remove first point 355 expected.pop_front(); // remove second point 356 expected.pop_front(); // remove third point 357 SphericalPointDistribution::Polygon_t remaining = 358 SphericalPointDistribution::matchSphericalPointDistributions( 359 polygon, 360 newpolygon); 361 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 362 } 363 364 // test with three points, full rotation 365 { 366 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 367 SphericalPointDistribution::Polygon_t polygon; 368 polygon += 369 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 370 RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 371 RotationAxis.rotateVector(Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 47.6/180*M_PI); 372 SphericalPointDistribution::Polygon_t newpolygon = 373 SPD.get<4>(); 374 SphericalPointDistribution::Polygon_t expected = newpolygon; 375 expected.pop_front(); // remove first point 376 expected.pop_front(); // remove second point 377 expected.pop_front(); // remove third point 378 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 379 iter != expected.end(); ++iter) 380 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 381 SphericalPointDistribution::Polygon_t remaining = 382 SphericalPointDistribution::matchSphericalPointDistributions( 383 polygon, 384 newpolygon); 385 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 386 } 234 387 } 235 388 … … 274 427 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 275 428 } 429 430 // test with two points, matching trivially 431 { 432 SphericalPointDistribution::Polygon_t polygon; 433 polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.); 434 SphericalPointDistribution::Polygon_t newpolygon = 435 SPD.get<5>(); 436 SphericalPointDistribution::Polygon_t expected = newpolygon; 437 expected.pop_front(); // remove first point 438 expected.pop_front(); // remove second point 439 SphericalPointDistribution::Polygon_t remaining = 440 SphericalPointDistribution::matchSphericalPointDistributions( 441 polygon, 442 newpolygon); 443 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 444 } 445 446 // test with two points, full rotation 447 { 448 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 449 SphericalPointDistribution::Polygon_t polygon; 450 polygon += 451 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180.*M_PI), 452 RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180.*M_PI); 453 SphericalPointDistribution::Polygon_t newpolygon = 454 SPD.get<5>(); 455 SphericalPointDistribution::Polygon_t expected = newpolygon; 456 expected.pop_front(); // remove first point 457 expected.pop_front(); // remove second point 458 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 459 iter != expected.end(); ++iter) 460 *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI); 461 SphericalPointDistribution::Polygon_t remaining = 462 SphericalPointDistribution::matchSphericalPointDistributions( 463 polygon, 464 newpolygon); 465 // the three remaining points sit on a plane that may be rotated arbitrarily 466 // so we cannot simply check for equality between expected and remaining 467 // hence, we just check that they are orthogonal to the first two points 468 CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() ); 469 for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin(); 470 fixiter != polygon.end(); ++fixiter) { 471 for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin(); 472 iter != remaining.end(); ++iter) { 473 CPPUNIT_ASSERT( (*fixiter).IsNormalTo(*iter) ); 474 } 475 } 476 } 477 478 // test with three points, matching trivially 479 { 480 SphericalPointDistribution::Polygon_t polygon; 481 polygon += 482 Vector(1.,0.,0.), 483 Vector(-1., 0.0, 0.0), 484 Vector(0.0, 1., 0.0); 485 SphericalPointDistribution::Polygon_t newpolygon = 486 SPD.get<5>(); 487 SphericalPointDistribution::Polygon_t expected = newpolygon; 488 expected.pop_front(); // remove first point 489 expected.pop_front(); // remove second point 490 expected.pop_front(); // remove third point 491 SphericalPointDistribution::Polygon_t remaining = 492 SphericalPointDistribution::matchSphericalPointDistributions( 493 polygon, 494 newpolygon); 495 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 496 } 497 498 // test with three points, full rotation 499 { 500 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 501 SphericalPointDistribution::Polygon_t polygon; 502 polygon += 503 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 504 RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 505 RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI); 506 SphericalPointDistribution::Polygon_t newpolygon = 507 SPD.get<5>(); 508 SphericalPointDistribution::Polygon_t expected = newpolygon; 509 expected.pop_front(); // remove first point 510 expected.pop_front(); // remove second point 511 expected.pop_front(); // remove third point 512 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 513 iter != expected.end(); ++iter) 514 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 515 SphericalPointDistribution::Polygon_t remaining = 516 SphericalPointDistribution::matchSphericalPointDistributions( 517 polygon, 518 newpolygon); 519 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 520 } 276 521 } 277 522 … … 316 561 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 317 562 } 563 564 // test with two points, matching trivially 565 { 566 SphericalPointDistribution::Polygon_t polygon; 567 polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.); 568 SphericalPointDistribution::Polygon_t newpolygon = 569 SPD.get<6>(); 570 SphericalPointDistribution::Polygon_t expected = newpolygon; 571 expected.pop_front(); // remove first point 572 expected.pop_front(); // remove second spoint 573 SphericalPointDistribution::Polygon_t remaining = 574 SphericalPointDistribution::matchSphericalPointDistributions( 575 polygon, 576 newpolygon); 577 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 578 } 579 580 // test with two points, full rotation 581 { 582 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 583 SphericalPointDistribution::Polygon_t polygon; 584 polygon += 585 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 586 RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 587 SphericalPointDistribution::Polygon_t newpolygon = 588 SPD.get<6>(); 589 SphericalPointDistribution::Polygon_t expected = newpolygon; 590 expected.pop_front(); // remove first point 591 expected.pop_front(); // remove second spoint 592 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 593 iter != expected.end(); ++iter) 594 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 595 SphericalPointDistribution::Polygon_t remaining = 596 SphericalPointDistribution::matchSphericalPointDistributions( 597 polygon, 598 newpolygon); 599 // the four remaining points sit on a plane that may have been rotated arbitrarily 600 // so we cannot simply check for equality between expected and remaining 601 // hence, we just check that they are orthogonal to the first two points 602 CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() ); 603 for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin(); 604 fixiter != polygon.end(); ++fixiter) { 605 for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin(); 606 iter != remaining.end(); ++iter) { 607 CPPUNIT_ASSERT( (*fixiter).IsNormalTo(*iter) ); 608 } 609 } 610 } 611 612 // test with three points, matching trivially 613 { 614 SphericalPointDistribution::Polygon_t polygon; 615 polygon += 616 Vector(1.,0.,0.), 617 Vector(-1., 0.0, 0.0), 618 Vector(0.0, 1., 0.0); 619 SphericalPointDistribution::Polygon_t newpolygon = 620 SPD.get<6>(); 621 SphericalPointDistribution::Polygon_t expected = newpolygon; 622 expected.pop_front(); // remove first point 623 expected.pop_front(); // remove second point 624 expected.pop_front(); // remove third point 625 SphericalPointDistribution::Polygon_t remaining = 626 SphericalPointDistribution::matchSphericalPointDistributions( 627 polygon, 628 newpolygon); 629 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 630 } 631 632 // test with three points, full rotation 633 { 634 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 635 SphericalPointDistribution::Polygon_t polygon; 636 polygon += 637 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 638 RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 639 RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI); 640 SphericalPointDistribution::Polygon_t newpolygon = 641 SPD.get<6>(); 642 SphericalPointDistribution::Polygon_t expected = newpolygon; 643 expected.pop_front(); // remove first point 644 expected.pop_front(); // remove second point 645 expected.pop_front(); // remove third point 646 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 647 iter != expected.end(); ++iter) 648 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 649 SphericalPointDistribution::Polygon_t remaining = 650 SphericalPointDistribution::matchSphericalPointDistributions( 651 polygon, 652 newpolygon); 653 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 654 } 318 655 } 319 656 … … 358 695 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 359 696 } 697 698 // test with two points, matching trivially 699 { 700 SphericalPointDistribution::Polygon_t polygon; 701 polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.); 702 SphericalPointDistribution::Polygon_t newpolygon = 703 SPD.get<7>(); 704 SphericalPointDistribution::Polygon_t expected = newpolygon; 705 expected.pop_front(); // remove first point 706 expected.pop_front(); // remove second point 707 SphericalPointDistribution::Polygon_t remaining = 708 SphericalPointDistribution::matchSphericalPointDistributions( 709 polygon, 710 newpolygon); 711 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 712 } 713 714 // test with two points, full rotation 715 { 716 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 717 SphericalPointDistribution::Polygon_t polygon; 718 polygon += 719 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 720 RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 721 SphericalPointDistribution::Polygon_t newpolygon = 722 SPD.get<7>(); 723 SphericalPointDistribution::Polygon_t expected = newpolygon; 724 expected.pop_front(); // remove first point 725 expected.pop_front(); // remove second point 726 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 727 iter != expected.end(); ++iter) 728 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 729 SphericalPointDistribution::Polygon_t remaining = 730 SphericalPointDistribution::matchSphericalPointDistributions( 731 polygon, 732 newpolygon); 733 // the five remaining points sit on a plane that may have been rotated arbitrarily 734 // so we cannot simply check for equality between expected and remaining 735 // hence, we just check that they are orthogonal to the first two points 736 CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() ); 737 for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin(); 738 fixiter != polygon.end(); ++fixiter) { 739 for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin(); 740 iter != remaining.end(); ++iter) { 741 CPPUNIT_ASSERT( (*fixiter).IsNormalTo(*iter) ); 742 } 743 } 744 } 745 746 // test with three points, matching trivially 747 { 748 SphericalPointDistribution::Polygon_t polygon; 749 polygon += 750 Vector(1.,0.,0.), 751 Vector(-1., 0.0, 0.0), 752 Vector(0.0, 1., 0.0); 753 SphericalPointDistribution::Polygon_t newpolygon = 754 SPD.get<7>(); 755 SphericalPointDistribution::Polygon_t expected = newpolygon; 756 expected.pop_front(); // remove first point 757 expected.pop_front(); // remove second point 758 expected.pop_front(); // remove third point 759 SphericalPointDistribution::Polygon_t remaining = 760 SphericalPointDistribution::matchSphericalPointDistributions( 761 polygon, 762 newpolygon); 763 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 764 } 765 766 // test with three points, full rotation 767 { 768 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 769 SphericalPointDistribution::Polygon_t polygon; 770 polygon += 771 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 772 RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 773 RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI); 774 SphericalPointDistribution::Polygon_t newpolygon = 775 SPD.get<7>(); 776 SphericalPointDistribution::Polygon_t expected = newpolygon; 777 expected.pop_front(); // remove first point 778 expected.pop_front(); // remove second point 779 expected.pop_front(); // remove third point 780 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 781 iter != expected.end(); ++iter) 782 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 783 SphericalPointDistribution::Polygon_t remaining = 784 SphericalPointDistribution::matchSphericalPointDistributions( 785 polygon, 786 newpolygon); 787 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 788 } 360 789 } 361 790 … … 400 829 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 401 830 } 831 832 // test with two points, matching trivially 833 { 834 SphericalPointDistribution::Polygon_t polygon; 835 polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.); 836 SphericalPointDistribution::Polygon_t newpolygon = 837 SPD.get<8>(); 838 SphericalPointDistribution::Polygon_t expected = newpolygon; 839 expected.pop_front(); // remove first point 840 expected.pop_front(); // remove second point 841 SphericalPointDistribution::Polygon_t remaining = 842 SphericalPointDistribution::matchSphericalPointDistributions( 843 polygon, 844 newpolygon); 845 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 846 } 847 848 // test with two points, full rotation 849 { 850 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 851 SphericalPointDistribution::Polygon_t polygon; 852 polygon += 853 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 854 RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 855 SphericalPointDistribution::Polygon_t newpolygon = 856 SPD.get<8>(); 857 SphericalPointDistribution::Polygon_t expected = newpolygon; 858 expected.pop_front(); // remove first point 859 expected.pop_front(); // remove second point 860 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 861 iter != expected.end(); ++iter) 862 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 863 SphericalPointDistribution::Polygon_t remaining = 864 SphericalPointDistribution::matchSphericalPointDistributions( 865 polygon, 866 newpolygon); 867 // the six remaining points sit on two planes that may have been rotated arbitrarily 868 // so we cannot simply check for equality between expected and remaining 869 // hence, we just check that they are orthogonal to the first two points 870 CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() ); 871 for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin(); 872 fixiter != polygon.end(); ++fixiter) { 873 SphericalPointDistribution::Polygon_t::const_iterator expectiter = expected.begin(); 874 SphericalPointDistribution::Polygon_t::const_iterator remainiter = remaining.begin(); 875 for (;remainiter != remaining.end(); ++expectiter, ++remainiter) { 876 // check that points in expected/remaining have same angle to the given ones 877 // CPPUNIT_ASSERT_EQUAL( (*expectiter).Angle(*fixiter), (*remainiter).Angle(*fixiter) ); 878 CPPUNIT_ASSERT( fabs( (*expectiter).Angle(*fixiter) - (*remainiter).Angle(*fixiter) ) 879 < std::numeric_limits<double>::epsilon()*1e4 ); 880 } 881 } 882 } 883 884 // test with three points, matching trivially 885 { 886 SphericalPointDistribution::Polygon_t polygon; 887 polygon += 888 Vector(1.,0.,0.), 889 Vector(-1., 0.0, 0.0), 890 Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0); 891 SphericalPointDistribution::Polygon_t newpolygon = 892 SPD.get<8>(); 893 SphericalPointDistribution::Polygon_t expected = newpolygon; 894 expected.pop_front(); // remove first point 895 expected.pop_front(); // remove second point 896 expected.pop_front(); // remove third point 897 SphericalPointDistribution::Polygon_t remaining = 898 SphericalPointDistribution::matchSphericalPointDistributions( 899 polygon, 900 newpolygon); 901 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 902 } 903 904 // test with three points, full rotation 905 { 906 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 907 SphericalPointDistribution::Polygon_t polygon; 908 polygon += 909 RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 910 RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 911 RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 47.6/180*M_PI); 912 SphericalPointDistribution::Polygon_t newpolygon = 913 SPD.get<8>(); 914 SphericalPointDistribution::Polygon_t expected = newpolygon; 915 expected.pop_front(); // remove first point 916 expected.pop_front(); // remove second point 917 expected.pop_front(); // remove third point 918 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); 919 iter != expected.end(); ++iter) 920 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 921 SphericalPointDistribution::Polygon_t remaining = 922 SphericalPointDistribution::matchSphericalPointDistributions( 923 polygon, 924 newpolygon); 925 CPPUNIT_ASSERT_EQUAL( expected, remaining ); 926 } 402 927 }
Note:
See TracChangeset
for help on using the changeset viewer.