Changeset ccf826


Ignore:
Timestamp:
May 28, 2010, 11:41:08 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
5589858
Parents:
42a101
Message:

Removed Vector::mirror() in favour of Plane::mirror()

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Plane.cpp

    r42a101 rccf826  
    182182};
    183183
     184Vector Plane::mirrorVector(const Vector &rhs) const {
     185  Vector helper = getVectorToPoint(rhs);
     186  // substract twice the Vector to the plane
     187  return rhs+2*helper;
     188}
     189
    184190/************ Methods inherited from Space ****************/
    185191
  • src/Plane.hpp

    r42a101 rccf826  
    5252  Vector GetIntersection(const Vector &Origin, const Vector &LineVector) const;
    5353
     54  Vector mirrorVector(const Vector &rhs) const;
     55
    5456  /****** Methods inherited from Space ***********/
    5557
  • src/Space.hpp

    r42a101 rccf826  
    1717  virtual ~Space();
    1818
     19  /**
     20   * Calculates the distance between a Space and a Vector.
     21   */
    1922  virtual double distance(const Vector &point) const=0;
     23
     24  /**
     25   * get the closest point inside the space to another point
     26   */
    2027  virtual Vector getClosestPoint(const Vector &point) const=0;
     28
     29  /**
     30   * get the shortest Vector from a point to a Space.
     31   *
     32   * The Vector always points from the given Vector to the point in space
     33   * returned by Plane::getClosestPoint().
     34   */
    2135  virtual Vector getVectorToPoint(const Vector &point) const;
     36
     37  /**
     38   * Test wether a point is contained in the space.
     39   *
     40   * returns true, when the point lies inside and false
     41   * otherwise.
     42   */
    2243  virtual bool isContained(const Vector &point) const;
     44
     45  /**
     46   * Tests if this space contains the center of the coordinate system.
     47   */
    2348  virtual bool hasZero() const;
    2449
  • src/molecule_geometry.cpp

    r42a101 rccf826  
    1616#include "molecule.hpp"
    1717#include "World.hpp"
     18#include "Plane.hpp"
    1819
    1920/************************************* Functions for class molecule *********************************/
     
    251252void molecule::Mirror(const Vector *n)
    252253{
    253   ActOnAllVectors( &Vector::Mirror, *n );
     254  Plane p(*n,0);
     255  // TODO: replace with simpler construct (e.g. Boost::foreach)
     256  // once the structure of the atom list is fully reworked
     257  atom *Walker = start;
     258  while (Walker->next != end) {
     259    Walker = Walker->next;
     260    (*Walker->node) = p.mirrorVector(*Walker->node);
     261  }
    254262};
    255263
  • src/unittests/PlaneUnittest.cpp

    r42a101 rccf826  
    153153  CPPUNIT_ASSERT(fabs(p4->distance(e1)-1) < MYEPSILON);
    154154  CPPUNIT_ASSERT_EQUAL(zeroVec,p4->getClosestPoint(e1));
    155 
    156 
    157 }
     155}
     156
     157void PlaneUnittest::mirrorTest(){
     158  Vector fixture;
     159
     160  // some Vectors that lie on the planes
     161  fixture = p1->mirrorVector(e1);
     162  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     163  fixture = p1->mirrorVector(e2);
     164  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     165  fixture = p1->mirrorVector(e3);
     166  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     167
     168  fixture = p2->mirrorVector(zeroVec);
     169  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     170  fixture = p2->mirrorVector(e1);
     171  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     172  fixture = p2->mirrorVector(e2);
     173  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     174
     175  fixture = p3->mirrorVector(zeroVec);
     176  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     177  fixture = p3->mirrorVector(e1);
     178  CPPUNIT_ASSERT_EQUAL(fixture,e1);
     179  fixture = p3->mirrorVector(e3);
     180  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     181
     182  fixture = p4->mirrorVector(zeroVec);
     183  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
     184  fixture = p4->mirrorVector(e2);
     185  CPPUNIT_ASSERT_EQUAL(fixture,e2);
     186  fixture = p4->mirrorVector(e3);
     187  CPPUNIT_ASSERT_EQUAL(fixture,e3);
     188
     189  // some Vectors outside of the planes
     190  {
     191    Vector t = (2./3.)*(e1+e2+e3);
     192    fixture = p1->mirrorVector(zeroVec);
     193    CPPUNIT_ASSERT_EQUAL(fixture,t);
     194  }
     195
     196  fixture = p2->mirrorVector(e3);
     197  CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
     198  fixture = p3->mirrorVector(e2);
     199  CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
     200  fixture = p4->mirrorVector(e1);
     201  CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
     202}
  • src/unittests/PlaneUnittest.hpp

    r42a101 rccf826  
    2020  CPPUNIT_TEST ( pointsTest );
    2121  CPPUNIT_TEST ( operationsTest );
     22  CPPUNIT_TEST ( mirrorTest );
    2223  CPPUNIT_TEST_SUITE_END();
    2324
     
    3031  void pointsTest();
    3132  void operationsTest();
     33  void mirrorTest();
    3234
    3335private:
  • src/vector.cpp

    r42a101 rccf826  
    602602};
    603603
    604 /** Mirrors atom against a given plane.
    605  * \param n[] normal vector of mirror plane.
    606  */
    607 void Vector::Mirror(const Vector &n)
    608 {
    609   double projection;
    610   projection = ScalarProduct(n)/n.NormSquared();    // remove constancy from n (keep as logical one)
    611   // withdraw projected vector twice from original one
    612   for (int i=NDIM;i--;)
    613     at(i) -= 2.*projection*n[i];
    614 };
    615 
    616604/** Calculates orthonormal vector to one given vectors.
    617605 * Just subtracts the projection onto the given vector from this vector.
  • src/vector.hpp

    r42a101 rccf826  
    6060  void ProjectIt(const Vector &y);
    6161  Vector Projection(const Vector &y) const;
    62   void Mirror(const Vector &x);
    6362  void ScaleAll(const double *factor);
    6463  void Scale(const double factor);
Note: See TracChangeset for help on using the changeset viewer.