Changeset 42a101 for src/unittests


Ignore:
Timestamp:
May 28, 2010, 8:25:27 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, 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_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
ccf826
Parents:
643e76
Message:

Removed RotateVector() function in favor of Line::rotateVector() method.

Line::rotateVector() is able to rotate any vector around any line in space.

Location:
src/unittests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/LineUnittest.cpp

    r643e76 r42a101  
    221221  CPPUNIT_ASSERT_THROW(la3->getIntersection(*lp1),SkewException);
    222222}
     223
     224void LineUnittest::rotationTest(){
     225  Vector fixture;
     226
     227  // rotate zero Vector along the axes lines by various degrees
     228  fixture = la1->rotateVector(zeroVec,1.);
     229  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     230  fixture = la2->rotateVector(zeroVec,1.);
     231  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     232  fixture = la3->rotateVector(zeroVec,1.);
     233  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     234
     235  fixture = la1->rotateVector(zeroVec,2.);
     236  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     237  fixture = la2->rotateVector(zeroVec,2.);
     238  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     239  fixture = la3->rotateVector(zeroVec,2.);
     240  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     241
     242  // rotate vectors on the axis around their lines
     243  fixture = la1->rotateVector(e1,1.);
     244  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     245  fixture = la2->rotateVector(e2,1.);
     246  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     247  fixture = la3->rotateVector(e3,1.);
     248  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     249
     250  fixture = la1->rotateVector(e1,2.);
     251  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     252  fixture = la2->rotateVector(e2,2.);
     253  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     254  fixture = la3->rotateVector(e3,2.);
     255  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     256
     257  // more vectors on the axis
     258  fixture = la1->rotateVector(2*e1,1.);
     259  CPPUNIT_ASSERT_EQUAL(fixture,2*e1);
     260  fixture = la2->rotateVector(2*e2,1.);
     261  CPPUNIT_ASSERT_EQUAL(fixture,2*e2);
     262  fixture = la3->rotateVector(2*e3,1.);
     263  CPPUNIT_ASSERT_EQUAL(fixture,2*e3);
     264
     265  fixture = la1->rotateVector(2*e1,2.);
     266  CPPUNIT_ASSERT_EQUAL(fixture,2*e1);
     267  fixture = la2->rotateVector(2*e2,2.);
     268  CPPUNIT_ASSERT_EQUAL(fixture,2*e2);
     269  fixture = la3->rotateVector(2*e3,2.);
     270  CPPUNIT_ASSERT_EQUAL(fixture,2*e3);
     271
     272  // negative factors
     273  fixture = la1->rotateVector(-1*e1,1.);
     274  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
     275  fixture = la2->rotateVector(-1*e2,1.);
     276  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
     277  fixture = la3->rotateVector(-1*e3,1.);
     278  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
     279
     280  fixture = la1->rotateVector(-1*e1,2.);
     281  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
     282  fixture = la2->rotateVector(-1*e2,2.);
     283  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
     284  fixture = la3->rotateVector(-1*e3,2.);
     285  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
     286
     287
     288
     289  // now the real rotations
     290  // e2 around e1
     291  fixture = la1->rotateVector(e2,0);
     292  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     293  fixture = la1->rotateVector(e2,1./2.*M_PI);
     294  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
     295  fixture = la1->rotateVector(e2,M_PI);
     296  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
     297  fixture = la1->rotateVector(e2,2*M_PI);
     298  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     299
     300  // e3 around e2
     301  fixture = la2->rotateVector(e3,0);
     302  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     303  fixture = la2->rotateVector(e3,1./2.*M_PI);
     304  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
     305  fixture = la2->rotateVector(e3,M_PI);
     306  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
     307  fixture = la2->rotateVector(e3,2*M_PI);
     308  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     309
     310  // e1 around e3
     311  fixture = la3->rotateVector(e1,0);
     312  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     313  fixture = la3->rotateVector(e1,1./2.*M_PI);
     314  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
     315  fixture = la3->rotateVector(e1,M_PI);
     316  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
     317  fixture = la3->rotateVector(e1,2*M_PI);
     318  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     319
     320
     321  // and some rotation around the plane lines
     322
     323  // Vectors on the line
     324  fixture = lp1->rotateVector(e1,1.);
     325  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     326  fixture = lp1->rotateVector(e2,1.);
     327  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     328
     329  fixture = lp2->rotateVector(e2,1.);
     330  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     331  fixture = lp2->rotateVector(e3,1.);
     332  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     333
     334  fixture = lp3->rotateVector(e3,1.);
     335  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     336  fixture = lp3->rotateVector(e1,1.);
     337  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     338
     339  // the real stuff
     340  fixture = lp1->rotateVector(zeroVec,M_PI);
     341  CPPUNIT_ASSERT_EQUAL(fixture,Vector(1,1,0));
     342  fixture = lp2->rotateVector(zeroVec,M_PI);
     343  CPPUNIT_ASSERT_EQUAL(fixture,Vector(0,1,1));
     344  fixture = lp3->rotateVector(zeroVec,M_PI);
     345  CPPUNIT_ASSERT_EQUAL(fixture,Vector(1,0,1));
     346
     347  fixture = lp1->rotateVector(zeroVec,2*M_PI);
     348  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     349  fixture = lp2->rotateVector(zeroVec,2*M_PI);
     350  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     351  fixture = lp3->rotateVector(zeroVec,2*M_PI);
     352  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     353}
  • src/unittests/LineUnittest.hpp

    r643e76 r42a101  
    2121  CPPUNIT_TEST ( isContainedTest );
    2222  CPPUNIT_TEST ( intersectionTest );
     23  CPPUNIT_TEST ( rotationTest );
    2324  CPPUNIT_TEST_SUITE_END();
    2425
     
    3132  void isContainedTest();
    3233  void intersectionTest();
     34  void rotationTest();
    3335
    3436private:
  • src/unittests/vectorunittest.cpp

    r643e76 r42a101  
    230230};
    231231
    232 /** UnitTest for vector rotations.
    233  */
    234 void VectorTest::VectorRotationTest()
    235 {
    236   fixture = Vector(-1.,0.,0.);
    237 
    238   // zero vector does not change
    239   fixture = RotateVector(zero,unit, 1.);
    240   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    241 
    242   fixture = RotateVector(zero, two, 1.);
    243   CPPUNIT_ASSERT_EQUAL( zero,  fixture);
    244 
    245   // vector on axis does not change
    246   fixture = RotateVector(unit,unit, 1.);
    247   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    248 
    249   // rotations
    250   fixture = RotateVector(otherunit, unit, M_PI);
    251   CPPUNIT_ASSERT_EQUAL( Vector(0.,-1.,0.), fixture );
    252 
    253   fixture = RotateVector(otherunit, unit, 2. * M_PI);
    254   CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    255 
    256   fixture = RotateVector(otherunit,unit, 0);
    257   CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    258 
    259   fixture = RotateVector(Vector(0.,0.,1.), notunit, M_PI);
    260   CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    261 }
    262 
    263232/**
    264233 * UnitTest for Vector::IsInParallelepiped().
  • src/unittests/vectorunittest.hpp

    r643e76 r42a101  
    2828    CPPUNIT_TEST ( NormalsTest );
    2929    CPPUNIT_TEST ( LineIntersectionTest );
    30     CPPUNIT_TEST ( VectorRotationTest );
    3130    CPPUNIT_TEST ( IsInParallelepipedTest );
    3231    CPPUNIT_TEST_SUITE_END();
Note: See TracChangeset for help on using the changeset viewer.