Changeset 0a4f7f for src/unittests/vectorunittest.cpp
- Timestamp:
- Apr 7, 2010, 3:45:38 PM (15 years ago)
- 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:
- 72e7fa
- Parents:
- f9352d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/vectorunittest.cpp
rf9352d r0a4f7f 17 17 #include "memoryusageobserver.hpp" 18 18 #include "vector.hpp" 19 #include "vector_ops.hpp" 19 20 #include "vectorunittest.hpp" 21 #include "Plane.hpp" 22 #include "Exceptions/LinearDependenceException.hpp" 20 23 21 24 #ifdef HAVE_TESTRUNNER … … 195 198 { 196 199 // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ??? 197 CPPUNIT_ASSERT_ EQUAL( true, fixture.GetIntersectionWithPlane(&unit, &zero, &zero, &two) );200 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unit, zero).GetIntersection(zero, two) ); 198 201 CPPUNIT_ASSERT_EQUAL( zero, fixture ); 199 202 200 203 // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ??? 201 CPPUNIT_ASSERT_ EQUAL( true, fixture.GetIntersectionWithPlane(&otherunit, &two, &unit, ¬unit) );204 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(otherunit, two).GetIntersection( unit, notunit) ); 202 205 CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture ); 203 206 204 207 // four vectors equal to zero 205 CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&zero, &zero, &zero, &zero, NULL) ); 208 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(zero, zero, zero, zero), LinearDependenceException); 209 //CPPUNIT_ASSERT_EQUAL( zero, fixture ); 210 211 // four vectors equal to unit 212 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, unit, unit, unit), LinearDependenceException); 213 //CPPUNIT_ASSERT_EQUAL( zero, fixture ); 214 215 // two equal lines 216 CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, two)); 217 CPPUNIT_ASSERT_EQUAL( unit, fixture ); 218 219 // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ??? 220 CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, otherunit) ); 221 CPPUNIT_ASSERT_EQUAL( unit, fixture ); 222 223 // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ??? 224 CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, zero, zero, two) ); 206 225 CPPUNIT_ASSERT_EQUAL( zero, fixture ); 207 226 208 // four vectors equal to unit 209 CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &unit, &unit, &unit, NULL) ); 227 // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ??? 228 CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, zero, otherunit) ); 229 CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture ); 230 }; 231 232 /** UnitTest for vector rotations. 233 */ 234 void VectorTest::VectorRotationTest() 235 { 236 fixture.Init(-1.,0.,0.); 237 238 // zero vector does not change 239 fixture = RotateVector(zero,unit, 1.); 210 240 CPPUNIT_ASSERT_EQUAL( zero, fixture ); 211 241 212 // two equal lines 213 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &two, NULL) ); 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.); 214 247 CPPUNIT_ASSERT_EQUAL( unit, fixture ); 215 248 216 // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???217 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &otherunit, NULL) );218 CPPUNIT_ASSERT_EQUAL( unit, fixture );219 220 // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???221 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &zero, &zero, &two, NULL) );222 CPPUNIT_ASSERT_EQUAL( zero, fixture );223 224 // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???225 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &zero, &otherunit, NULL) );226 CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );227 };228 229 /** UnitTest for vector rotations.230 */231 void VectorTest::VectorRotationTest()232 {233 fixture.Init(-1.,0.,0.);234 235 // zero vector does not change236 fixture.CopyVector(&zero);237 fixture.RotateVector(&unit, 1.);238 CPPUNIT_ASSERT_EQUAL( zero, fixture );239 240 fixture.RotateVector(&two, 1.);241 CPPUNIT_ASSERT_EQUAL( zero, fixture);242 243 // vector on axis does not change244 fixture.CopyVector(&unit);245 fixture.RotateVector(&unit, 1.);246 CPPUNIT_ASSERT_EQUAL( unit, fixture );247 248 fixture.RotateVector(&unit, 1.);249 CPPUNIT_ASSERT_EQUAL( unit, fixture );250 251 249 // rotations 252 fixture.CopyVector(&otherunit); 253 fixture.RotateVector(&unit, M_PI); 250 fixture = RotateVector(otherunit, unit, M_PI); 254 251 CPPUNIT_ASSERT_EQUAL( Vector(0.,-1.,0.), fixture ); 255 252 256 fixture.CopyVector(&otherunit); 257 fixture.RotateVector(&unit, 2. * M_PI); 253 fixture = RotateVector(otherunit, unit, 2. * M_PI); 258 254 CPPUNIT_ASSERT_EQUAL( otherunit, fixture ); 259 255 260 fixture.CopyVector(&otherunit); 261 fixture.RotateVector(&unit, 0); 256 fixture = RotateVector(otherunit,unit, 0); 262 257 CPPUNIT_ASSERT_EQUAL( otherunit, fixture ); 263 258 264 fixture.Init(0.,0.,1.); 265 fixture.RotateVector(¬unit, M_PI); 259 fixture = RotateVector(Vector(0.,0.,1.), notunit, M_PI); 266 260 CPPUNIT_ASSERT_EQUAL( otherunit, fixture ); 267 261 }
Note:
See TracChangeset
for help on using the changeset viewer.