Changeset f932b7
- Timestamp:
- Jun 18, 2010, 2:40:02 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:
- 0d5dce
- Parents:
- 394529
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Line.cpp
r394529 rf932b7 215 215 } 216 216 217 std::vector<Vector> Line::getSphereIntersections() const{ 218 std::vector<Vector> res; 219 220 // line is kept in normalized form, so we can skip a lot of calculations 221 double discriminant = 1-origin->NormSquared(); 222 // we might have 2, 1 or 0 solutions, depending on discriminant 223 if(discriminant>=0){ 224 if(discriminant==0){ 225 res.push_back(*origin); 226 } 227 else{ 228 Vector helper = sqrt(discriminant)*(*direction); 229 res.push_back(*origin+helper); 230 res.push_back(*origin-helper); 231 } 232 } 233 return res; 234 } 235 217 236 Line makeLineThrough(const Vector &x1, const Vector &x2){ 218 237 if(x1==x2){ -
src/Line.hpp
r394529 rf932b7 38 38 Plane getOrthogonalPlane(const Vector &origin) const; 39 39 40 std::vector<Vector> getSphereIntersections() const; 41 40 42 private: 41 43 std::auto_ptr<Vector> origin; -
src/unittests/LineUnittest.cpp
r394529 rf932b7 352 352 CPPUNIT_ASSERT_EQUAL(fixture,zeroVec); 353 353 } 354 355 void LineUnittest::sphereIntersectionTest(){ 356 { 357 std::vector<Vector> res = la1->getSphereIntersections(); 358 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 359 CPPUNIT_ASSERT(testDirection(res[0],e1)); 360 CPPUNIT_ASSERT(testDirection(res[1],e1)); 361 CPPUNIT_ASSERT(res[0]!=res[1]); 362 } 363 364 { 365 std::vector<Vector> res = la2->getSphereIntersections(); 366 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 367 CPPUNIT_ASSERT(testDirection(res[0],e2)); 368 CPPUNIT_ASSERT(testDirection(res[1],e2)); 369 CPPUNIT_ASSERT(res[0]!=res[1]); 370 } 371 372 { 373 std::vector<Vector> res = la3->getSphereIntersections(); 374 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 375 CPPUNIT_ASSERT(testDirection(res[0],e3)); 376 CPPUNIT_ASSERT(testDirection(res[1],e3)); 377 CPPUNIT_ASSERT(res[0]!=res[1]); 378 } 379 380 { 381 std::vector<Vector> res = lp1->getSphereIntersections(); 382 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 383 CPPUNIT_ASSERT((res[0]==e1) || (res[0]==e2)); 384 CPPUNIT_ASSERT((res[1]==e1) || (res[1]==e2)); 385 CPPUNIT_ASSERT(res[0]!=res[1]); 386 } 387 388 { 389 std::vector<Vector> res = lp2->getSphereIntersections(); 390 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 391 CPPUNIT_ASSERT((res[0]==e2) || (res[0]==e3)); 392 CPPUNIT_ASSERT((res[1]==e2) || (res[1]==e3)); 393 CPPUNIT_ASSERT(res[0]!=res[1]); 394 } 395 396 { 397 std::vector<Vector> res = lp3->getSphereIntersections(); 398 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 399 CPPUNIT_ASSERT((res[0]==e3) || (res[0]==e1)); 400 CPPUNIT_ASSERT((res[1]==e3) || (res[1]==e1)); 401 CPPUNIT_ASSERT(res[0]!=res[1]); 402 } 403 } -
src/unittests/LineUnittest.hpp
r394529 rf932b7 22 22 CPPUNIT_TEST ( intersectionTest ); 23 23 CPPUNIT_TEST ( rotationTest ); 24 CPPUNIT_TEST ( sphereIntersectionTest ); 24 25 CPPUNIT_TEST_SUITE_END(); 25 26 … … 33 34 void intersectionTest(); 34 35 void rotationTest(); 36 void sphereIntersectionTest(); 35 37 36 38 private:
Note:
See TracChangeset
for help on using the changeset viewer.