Changeset 125841 for src/Shapes
- Timestamp:
- Sep 26, 2012, 5:23:51 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:
- d6203a
- Parents:
- 7e6a1b
- git-author:
- Michael Ankele <ankele@…> (08/27/12 13:12:27)
- git-committer:
- Frederik Heber <heber@…> (09/26/12 17:23:51)
- Location:
- src/Shapes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Shapes/BaseShapes.cpp
r7e6a1b r125841 98 98 { 99 99 std::vector<Vector> PointsOnSurface; 100 101 double PI=3.14159265358979323846; 102 double a=4*PI/N; 100 if (true) { 101 // Exactly N points but not symmetric. 102 103 // This formula is derived by finding a curve on the sphere that spirals down from 104 // the north pole to the south pole keeping a constant distance between consecutive turns. 105 // The curve is then parametrized by arch length and evaluated in constant intervals. 106 double a = sqrt(N) * 2; 107 for (int i=0; i<N; i++){ 108 double t0 = ((double)i + 0.5) / (double)N; 109 double t = (sqrt(t0) - sqrt(1.0 - t0) + 1.0) / 2.0 * M_PI; 110 Vector point; 111 point.Zero(); 112 point[0] = sin(t) * sin(t * a); 113 point[1] = sin(t) * cos(t * a); 114 point[2] = cos(t); 115 PointsOnSurface.push_back(point); 116 } 117 ASSERT(PointsOnSurface.size() == N, 118 "Sphere_impl::getHomogeneousPointsOnSurface() did not create " 119 +::toString(N)+" but "+::toString(PointsOnSurface.size())+" points."); 120 } else { 121 // Symmetric but only approximately N points. 122 double a=4*M_PI/N; 103 123 double d= sqrt(a); 104 int Mtheta=int( PI/d);105 double dtheta= PI/Mtheta;124 int Mtheta=int(M_PI/d); 125 double dtheta=M_PI/Mtheta; 106 126 double dphi=a/dtheta; 107 127 for (int m=0; m<Mtheta; m++) 108 128 { 109 double theta=PI*(m+0.5)/Mtheta; 110 int Mphi=int(2*PI*sin(theta)/dphi); 111 for (int n=0; n<Mphi;n++) 112 { 113 double phi= 2*PI*n/Mphi; 114 Vector point; 115 point.Zero(); 116 point[0]=sin(theta)*cos(phi); 117 point[1]=sin(theta)*sin(phi); 118 point[2]=cos(theta); 119 PointsOnSurface.push_back(point); 120 } 121 } 122 /*const double dlength = M_PI*(3.-sqrt(5.)); 123 double length = 0; 124 const double dz = 2.0/N; 125 double z = 1. - dz/2.; 126 Vector point; 127 for (size_t ka = 0; ka<N; ka++){ 128 const double r = sqrt(1.-z*z); 129 point.Zero(); 130 point[0] = cos(length)*r; 131 point[1] = sin(length)*r; 132 point[2] = z; 133 PointsOnSurface.push_back(point); 134 z = z - dz; 135 length = length + dlength;*/ 136 137 // ASSERT(PointsOnSurface.size() == N, 138 // "Sphere_impl::getHomogeneousPointsOnSurface() did not create " 139 // +::toString(N)+" but "+::toString(PointsOnSurface.size())+" points."); 129 double theta=M_PI*(m+0.5)/Mtheta; 130 int Mphi=int(2*M_PI*sin(theta)/dphi); 131 for (int n=0; n<Mphi;n++) 132 { 133 double phi= 2*M_PI*n/Mphi; 134 Vector point; 135 point.Zero(); 136 point[0]=sin(theta)*cos(phi); 137 point[1]=sin(theta)*sin(phi); 138 point[2]=cos(theta); 139 PointsOnSurface.push_back(point); 140 } 141 } 142 } 140 143 return PointsOnSurface; 141 144 } -
src/Shapes/unittests/BaseShapesUnitTest.cpp
r7e6a1b r125841 652 652 void BaseShapesTest::PointsOnSurfaceTest(){ 653 653 Shape s = Sphere(); 654 const size_t N = 200; 655 std::vector<Vector> PointsOnSurface = s.getHomogeneousPointsOnSurface(N); 656 for (std::vector<Vector>::const_iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 657 CPPUNIT_ASSERT(fabs(1. - (*iter).NormSquared()) < MYEPSILON); 654 for (size_t N = 20; N <=200; N+= 45) { 655 std::vector<Vector> PointsOnSurface = s.getHomogeneousPointsOnSurface(N); 656 for (std::vector<Vector>::const_iterator iter = PointsOnSurface.begin(); 657 iter != PointsOnSurface.end(); 658 ++iter) { 659 CPPUNIT_ASSERT(fabs(1. - (*iter).NormSquared()) < MYEPSILON); 660 } 661 CPPUNIT_ASSERT_EQUAL( N, PointsOnSurface.size()); 658 662 } 659 CPPUNIT_ASSERT_EQUAL((size_t)194, PointsOnSurface.size());660 663 }
Note:
See TracChangeset
for help on using the changeset viewer.