Changeset 6acc2f3 for src/Shapes/unittests/ShapeOpsUnitTest.cpp
- Timestamp:
- Mar 28, 2012, 3:17:38 PM (13 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:
- 5a8d61
- Parents:
- 84721b
- git-author:
- Frederik Heber <heber@…> (01/18/12 20:17:24)
- git-committer:
- Frederik Heber <heber@…> (03/28/12 15:17:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Shapes/unittests/ShapeOpsUnitTest.cpp ¶
r84721b r6acc2f3 23 23 24 24 #include <cmath> 25 #include <limits> 25 26 26 27 #ifdef HAVE_TESTRUNNER … … 107 108 } 108 109 110 void ShapeOpsTest::getCenterTest() 111 { 112 Shape s = Sphere(); 113 Shape t = Sphere(Vector(2.,0.,0.),1.); 114 Vector offset(1.,0.,0); 115 RealSpaceMatrix M; 116 M.setRotation(45.,0.,0.); 117 118 // Sphere 119 { 120 // sphere at origin 121 CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,0), s.getCenter() ); 122 123 // translated sphere 124 CPPUNIT_ASSERT_EQUAL( offset, translate(s, offset).getCenter() ); 125 126 // resized sphere 127 CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,0), resize(s, 2.).getCenter() ); 128 129 // stretched sphere 130 CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,0), stretch(s, Vector(2.,1.,1.)).getCenter() ); 131 132 // transformed sphere 133 CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,0), transform(s, M).getCenter() ); 134 135 // resized and translated sphere 136 CPPUNIT_ASSERT_EQUAL( offset, translate(resize(s, 2.), offset).getCenter() ); 137 } 138 139 // AND spheres 140 { 141 // sphere at origin 142 CPPUNIT_ASSERT_EQUAL( Vector(1.,0.,0), (s && t).getCenter() ); 143 144 // translated sphere 145 CPPUNIT_ASSERT_EQUAL( Vector(2.,0.,0), translate((s && t), offset).getCenter() ); 146 147 // resized sphere 148 CPPUNIT_ASSERT_EQUAL( Vector(1.,0.,0), resize((s && t), 2.).getCenter() ); 149 150 // stretched sphere 151 CPPUNIT_ASSERT_EQUAL( Vector(1.5,0.,0), (stretch(s, Vector(2.,1.,1.)) && t).getCenter() ); 152 153 // transformed sphere 154 CPPUNIT_ASSERT_EQUAL( Vector(1.,0.,0), (transform(s, M) && t).getCenter() ); 155 156 // resized and translated sphere 157 CPPUNIT_ASSERT_EQUAL( Vector(2.,0.,0), translate(resize((s && t), 2.), offset).getCenter() ); 158 } 159 160 // OR spheres 161 { 162 // sphere at origin 163 CPPUNIT_ASSERT_EQUAL( Vector(1.,0.,0), (s || t).getCenter() ); 164 165 // translated sphere 166 CPPUNIT_ASSERT_EQUAL( Vector(2.,0.,0), translate((s || t), offset).getCenter() ); 167 168 // resized sphere 169 CPPUNIT_ASSERT_EQUAL( Vector(1.,0.,0), resize((s || t), 2.).getCenter() ); 170 171 // stretched sphere 172 CPPUNIT_ASSERT_EQUAL( Vector(0.5,0.,0), (stretch(s, Vector(2.,1.,1.)) || t).getCenter() ); 173 174 // transformed sphere 175 CPPUNIT_ASSERT_EQUAL( Vector(1.,0.,0), (transform(s, M) || t).getCenter() ); 176 177 // resized and translated sphere 178 CPPUNIT_ASSERT_EQUAL( Vector(2.,0.,0), translate(resize((s || t), 2.), offset).getCenter() ); 179 } 180 181 // NOT spheres 182 { 183 // sphere at origin 184 CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,0), (!s).getCenter() ); 185 } 186 } 187 188 void ShapeOpsTest::getRadiusTest() 189 { 190 Shape s = Sphere(); 191 Shape t = Sphere(Vector(2.,0.,0.),1.); 192 Vector offset(1.,0.,0); 193 RealSpaceMatrix M; 194 M.setRotation(45.,0.,0.); 195 196 // Sphere 197 { 198 // sphere at origin 199 CPPUNIT_ASSERT_EQUAL( 1., s.getRadius() ); 200 201 // translated sphere 202 CPPUNIT_ASSERT_EQUAL( 1., translate(s, offset).getRadius() ); 203 204 // resized sphere 205 CPPUNIT_ASSERT_EQUAL( 2., resize(s, 2.).getRadius() ); 206 207 // stretched sphere 208 CPPUNIT_ASSERT_EQUAL( 2., stretch(s, Vector(2.,1.,1.)).getRadius() ); 209 210 // transformed sphere 211 CPPUNIT_ASSERT_EQUAL( 1., transform(s, M).getRadius() ); 212 213 // resized and translated sphere 214 CPPUNIT_ASSERT_EQUAL( 2., translate(resize(s, 2.), offset).getRadius() ); 215 } 216 217 // AND spheres 218 { 219 // sphere at origin 220 CPPUNIT_ASSERT_EQUAL( 1., (s && t).getRadius() ); 221 222 // translated sphere 223 CPPUNIT_ASSERT_EQUAL( 1., translate((s && t), offset).getRadius() ); 224 225 // resized sphere 226 CPPUNIT_ASSERT_EQUAL( 2., resize((s && t), 2.).getRadius() ); 227 228 // stretched sphere 229 CPPUNIT_ASSERT_EQUAL( 1., (stretch(s, Vector(2.,1.,1.)) && t).getRadius() ); 230 231 // transformed sphere 232 CPPUNIT_ASSERT_EQUAL( 1., (transform(s, M) && t).getRadius() ); 233 234 // resized and translated sphere 235 CPPUNIT_ASSERT_EQUAL( 2., translate(resize((s && t), 2.), offset).getRadius() ); 236 } 237 238 // OR spheres 239 { 240 // sphere at origin 241 CPPUNIT_ASSERT_EQUAL( 2., (s || t).getRadius() ); 242 243 // translated sphere 244 CPPUNIT_ASSERT_EQUAL( 2., translate((s || t), offset).getRadius() ); 245 246 // resized sphere 247 CPPUNIT_ASSERT_EQUAL( 4., resize((s || t), 2.).getRadius() ); 248 249 // stretched sphere 250 CPPUNIT_ASSERT_EQUAL( 2.5, (stretch(s, Vector(2.,1.,1.)) || t).getRadius() ); 251 252 // transformed sphere 253 CPPUNIT_ASSERT_EQUAL( 2., (transform(s, M) || t).getRadius() ); 254 255 // resized and translated sphere 256 CPPUNIT_ASSERT_EQUAL( 4., translate(resize((s || t), 2.), offset).getRadius() ); 257 } 258 259 // NOT spheres 260 { 261 // sphere at origin 262 CPPUNIT_ASSERT_EQUAL( std::numeric_limits<double>::infinity(), (!s).getRadius() ); 263 } 264 } 265
Note:
See TracChangeset
for help on using the changeset viewer.