Changeset 0eb8f4
- Timestamp:
- Sep 26, 2012, 5:24:33 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:
- 6f0507e
- Parents:
- 52575c
- git-author:
- Gregor Bollerhey <bollerhe@…> (06/18/12 14:43:14)
- git-committer:
- Frederik Heber <heber@…> (09/26/12 17:24:33)
- Location:
- src/Shapes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Shapes/BaseShapes.cpp ¶
r52575c r0eb8f4 29 29 #include "CodePatterns/Assert.hpp" 30 30 #include "LinearAlgebra/Vector.hpp" 31 #include "LinearAlgebra/RealSpaceMatrix.hpp" 31 32 #include "LinearAlgebra/Line.hpp" 32 33 #include "LinearAlgebra/Plane.hpp" … … 36 37 #include <cmath> 37 38 #include <algorithm> 39 40 // CYLINDER CODE 41 // ---------------------------------------------------------------------------- 42 bool Cylinder_impl::isInside(const Vector &point) const { 43 return (Vector(point[0], point[1], 0.0).NormSquared() < 1.0+MYEPSILON) && 44 (point[2] > -1.0-MYEPSILON) && (point[2] < 1.0+MYEPSILON); 45 } 46 47 bool Cylinder_impl::isOnSurface(const Vector &point) const { 48 return fabs(Vector(point[0], point[1], 0.0).NormSquared()-1.0)<MYEPSILON && 49 (point[2] > -1.0-MYEPSILON) && (point[2] < 1.0+MYEPSILON); 50 51 } 52 53 Vector Cylinder_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException) { 54 if(!isOnSurface(point)){ 55 throw NotOnSurfaceException() << ShapeVector(&point); 56 } 57 58 if ((fabs(point[2]-1)<MYEPSILON) || (fabs(point[2])<MYEPSILON)) 59 return Vector(0.0, 0.0, point[2]); 60 else 61 return Vector(point[0], point[1], 0.0); 62 } 63 64 Vector Cylinder_impl::getCenter() const 65 { 66 return Vector(0.0, 0.0, 0.0); 67 } 68 69 double Cylinder_impl::getRadius() const 70 { 71 return 1.0; 72 } 73 74 double Cylinder_impl::getVolume() const 75 { 76 return M_PI*2.0; // pi r^2 h 77 } 78 79 double Cylinder_impl::getSurfaceArea() const 80 { 81 return 2.0*M_PI*2.0; // 2 pi r h 82 } 83 84 LineSegmentSet Cylinder_impl::getLineIntersections(const Line &line) const { 85 // TODO 86 ASSERT(0, "Cylinder_impl::getLineIntersections - not implemented."); 87 } 88 89 std::string Cylinder_impl::toString() const 90 { 91 return "Cylinder()"; 92 } 93 94 enum ShapeType Cylinder_impl::getType() const 95 { 96 return CylinderType; 97 } 98 99 std::vector<Vector> Cylinder_impl::getHomogeneousPointsOnSurface(const size_t N) const { 100 // TODO 101 ASSERT(0, "Cylinder_impl::getHomogeneousPointsOnSurface - not implemented."); 102 } 103 104 std::vector<Vector> Cylinder_impl::getHomogeneousPointsInVolume(const size_t N) const { 105 // TODO 106 ASSERT(0, "Cylinder_impl::getHomogeneousPointsInVolume - not implemented."); 107 } 108 109 Shape Cylinder() { 110 Shape::impl_ptr impl = Shape::impl_ptr(new Cylinder_impl()); 111 return Shape(impl); 112 } 113 114 Shape Cylinder(const Vector ¢er, const double xrot, const double yrot, 115 const double height, const double radius) 116 { 117 RealSpaceMatrix rot; 118 rot.setRotation(xrot, yrot, 0.0); 119 120 return translate( 121 transform( 122 stretch( 123 Cylinder(), 124 Vector(radius, radius, height*0.5)), 125 rot), 126 center); 127 } 128 // ---------------------------------------------------------------------------- 38 129 39 130 bool Sphere_impl::isInside(const Vector &point) const{ -
TabularUnified src/Shapes/BaseShapes.hpp ¶
r52575c r0eb8f4 17 17 #include "Shapes/Shape.hpp" 18 18 19 Shape Cylinder(); 20 Shape Cylinder(const Vector ¢er, const double xrot, const double yrot, 21 const double height, const double radius); 19 22 Shape Sphere(); 20 23 Shape Sphere(const Vector ¢er,double radius); -
TabularUnified src/Shapes/BaseShapes_impl.hpp ¶
r52575c r0eb8f4 21 21 #include "Shapes/ShapeExceptions.hpp" 22 22 #include "Shapes/ShapeType.hpp" 23 24 class Cylinder_impl : public Shape_impl { 25 virtual bool isInside(const Vector &point) const; 26 virtual bool isOnSurface(const Vector &point) const; 27 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 28 virtual Vector getCenter() const; 29 virtual double getRadius() const; 30 virtual double getVolume() const; 31 virtual double getSurfaceArea() const; 32 virtual LineSegmentSet getLineIntersections(const Line&) const; 33 virtual std::string toString() const; 34 virtual enum ShapeType getType() const; 35 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 36 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 37 }; 23 38 24 39 class Sphere_impl : public Shape_impl { -
TabularUnified src/Shapes/ShapeType.hpp ¶
r52575c r0eb8f4 22 22 PolygonType, 23 23 CombinedType, 24 MAX_ShapeType 24 MAX_ShapeType, 25 CylinderType 25 26 }; 26 27 -
TabularUnified src/Shapes/unittests/BaseShapesUnitTest.cpp ¶
r52575c r0eb8f4 78 78 {} 79 79 80 void BaseShapesTest::cylinderTest() 81 { 82 Shape s = Cylinder(); 83 // z = 0 84 // Quadrant 1 1 85 CPPUNIT_ASSERT( s.isInside(v000)); 86 CPPUNIT_ASSERT( s.isInside(v100)); 87 CPPUNIT_ASSERT(!s.isInside(v110)); 88 CPPUNIT_ASSERT( s.isInside(v010)); 89 // Quadrant 0 1 90 CPPUNIT_ASSERT(!s.isInside(v210)); 91 CPPUNIT_ASSERT( s.isInside(v200)); 92 // Quadrant 0 0 93 CPPUNIT_ASSERT(!s.isInside(v220)); 94 CPPUNIT_ASSERT( s.isInside(v020)); 95 // Quadrant 1 0 96 CPPUNIT_ASSERT(!s.isInside(v120)); 97 98 // z = 1 99 // Quadrant 1 1 100 CPPUNIT_ASSERT( s.isInside(v001)); 101 CPPUNIT_ASSERT( s.isInside(v101)); 102 CPPUNIT_ASSERT(!s.isInside(v111)); 103 CPPUNIT_ASSERT( s.isInside(v011)); 104 // Quadrant 0 1 105 CPPUNIT_ASSERT(!s.isInside(v211)); 106 CPPUNIT_ASSERT( s.isInside(v201)); 107 // Quadrant 0 0 108 CPPUNIT_ASSERT(!s.isInside(v221)); 109 CPPUNIT_ASSERT( s.isInside(v021)); 110 // Quadrant 1 0 111 CPPUNIT_ASSERT(!s.isInside(v121)); 112 113 // z = 2 114 // Quadrant 1 1 115 CPPUNIT_ASSERT( s.isInside(v002)); 116 CPPUNIT_ASSERT( s.isInside(v102)); 117 CPPUNIT_ASSERT(!s.isInside(v112)); 118 CPPUNIT_ASSERT( s.isInside(v012)); 119 // Quadrant 0 1 120 CPPUNIT_ASSERT(!s.isInside(v212)); 121 CPPUNIT_ASSERT( s.isInside(v202)); 122 // Quadrant 0 0 123 CPPUNIT_ASSERT(!s.isInside(v222)); 124 CPPUNIT_ASSERT( s.isInside(v022)); 125 // Quadrant 1 0 126 CPPUNIT_ASSERT(!s.isInside(v122)); 127 128 129 // More special cylinder 130 s = Cylinder(Vector(0.5, 0.5, 0.0), 0.0, 30.0/180.0*M_PI, 4.0, 1.5); 131 132 CPPUNIT_ASSERT(!s.isInside(v222)); 133 CPPUNIT_ASSERT(!s.isInside(v022)); 134 CPPUNIT_ASSERT(!s.isInside(v122)); 135 CPPUNIT_ASSERT( s.isInside(v202)); 136 CPPUNIT_ASSERT( s.isInside(v002)); 137 CPPUNIT_ASSERT( s.isInside(v102)); 138 CPPUNIT_ASSERT( s.isInside(v212)); 139 CPPUNIT_ASSERT( s.isInside(v012)); 140 CPPUNIT_ASSERT( s.isInside(v112)); 141 142 CPPUNIT_ASSERT(!s.isInside(v220)); 143 CPPUNIT_ASSERT(!s.isInside(v020)); 144 CPPUNIT_ASSERT(!s.isInside(v120)); 145 CPPUNIT_ASSERT( s.isInside(v200)); 146 CPPUNIT_ASSERT( s.isInside(v000)); 147 CPPUNIT_ASSERT( s.isInside(v100)); 148 CPPUNIT_ASSERT( s.isInside(v210)); 149 CPPUNIT_ASSERT( s.isInside(v010)); 150 CPPUNIT_ASSERT( s.isInside(v110)); 151 152 CPPUNIT_ASSERT(!s.isInside(v221)); 153 CPPUNIT_ASSERT(!s.isInside(v021)); 154 CPPUNIT_ASSERT(!s.isInside(v121)); 155 CPPUNIT_ASSERT(!s.isInside(v201)); 156 CPPUNIT_ASSERT( s.isInside(v001)); 157 CPPUNIT_ASSERT( s.isInside(v101)); 158 CPPUNIT_ASSERT(!s.isInside(v211)); 159 CPPUNIT_ASSERT( s.isInside(v011)); 160 CPPUNIT_ASSERT( s.isInside(v111)); 161 } 80 162 81 163 void BaseShapesTest::baseShapesTest(){ -
TabularUnified src/Shapes/unittests/BaseShapesUnitTest.hpp ¶
r52575c r0eb8f4 30 30 CPPUNIT_TEST ( operatorTest ); 31 31 CPPUNIT_TEST ( PointsOnSurfaceTest ); 32 CPPUNIT_TEST ( cylinderTest ); 32 33 CPPUNIT_TEST_SUITE_END(); 33 34 … … 41 42 void operatorTest(); 42 43 void PointsOnSurfaceTest(); 44 void cylinderTest(); 43 45 44 46 // a lot of vectors.
Note:
See TracChangeset
for help on using the changeset viewer.