Changeset 31fb1d
- Timestamp:
- Aug 11, 2010, 2:58:43 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:
- 2b7d1b
- Parents:
- 03c902
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MapOfActions.cpp
r03c902 r31fb1d 256 256 DescriptionMap["version"] = "show version"; 257 257 // keys for values 258 DescriptionMap["angle-x"] = "angle of a rotation around x axis"; 259 DescriptionMap["angle-y"] = "angle of a rotation around y axis"; 260 DescriptionMap["angle-z"] = "angle of a rotation around z axis"; 258 261 DescriptionMap["bin-output-file"] = "name of the bin output file"; 259 262 DescriptionMap["bin-end"] = "start of the last bin"; … … 383 386 384 387 // value types for the values 388 TypeMap["angle-x"] = &typeid(double); 389 TypeMap["angle-y"] = &typeid(double); 390 TypeMap["angle-z"] = &typeid(double); 385 391 TypeMap["bin-output-file"] = &typeid(std::string); 386 392 TypeMap["bin-end"] = &typeid(double); … … 583 589 584 590 // hidden arguments 591 hidden.insert("angle-x"); 592 hidden.insert("angle-y"); 593 hidden.insert("angle-z"); 585 594 hidden.insert("bin-end"); 586 595 hidden.insert("bin-output-file"); -
src/Actions/SelectionAction/AllAtomsInsideCuboidAction.cpp
r03c902 r31fb1d 20 20 #include "Helpers/Log.hpp" 21 21 #include "Helpers/Verbose.hpp" 22 #include "LinearAlgebra/Matrix.hpp" 22 23 #include "LinearAlgebra/Vector.hpp" 23 24 #include "Shapes/BaseShapes.hpp" … … 40 41 class SelectionAllAtomsInsideCuboidState : public ActionState { 41 42 public: 42 SelectionAllAtomsInsideCuboidState(std::vector<atom*> _selectedAtoms, const Vector &_position, const Vector &_extension ) :43 SelectionAllAtomsInsideCuboidState(std::vector<atom*> _selectedAtoms, const Vector &_position, const Vector &_extension, const double _Xangle, const double _Yangle, const double _Zangle) : 43 44 selectedAtoms(_selectedAtoms), 44 45 position(_position), 45 extension(_extension) 46 extension(_extension), 47 Xangle(_Xangle), 48 Yangle(_Yangle), 49 Zangle(_Zangle) 46 50 {} 47 51 std::vector<atom*> selectedAtoms; 48 52 Vector position; 49 53 Vector extension; 54 double Xangle; 55 double Yangle; 56 double Zangle; 50 57 }; 51 58 … … 65 72 }; 66 73 74 void SelectionAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle) { 75 ValueStorage::getInstance().setCurrentValue(SelectionAllAtomsInsideCuboidAction::NAME, extension); 76 ValueStorage::getInstance().setCurrentValue("position", position); 77 ValueStorage::getInstance().setCurrentValue("angle-x", Xangle); 78 ValueStorage::getInstance().setCurrentValue("angle-y", Yangle); 79 ValueStorage::getInstance().setCurrentValue("angle-z", Zangle); 80 ActionRegistry::getInstance().getActionByName(SelectionAllAtomsInsideCuboidAction::NAME)->call(Action::NonInteractive); 81 }; 82 67 83 Dialog* SelectionAllAtomsInsideCuboidAction::fillDialog(Dialog *dialog) { 68 84 ASSERT(dialog,"No Dialog given when filling action dialog"); … … 78 94 Vector position; 79 95 Vector extension; 96 double Xangle = 0.; 97 double Yangle = 0.; 98 double Zangle = 0.; 99 Matrix RotationMatrix; 80 100 81 101 ValueStorage::getInstance().queryCurrentValue("position", position); 82 102 ValueStorage::getInstance().queryCurrentValue(NAME, extension); 103 // check whether a rotation is given. 104 if (ValueStorage::getInstance().queryCurrentValue("angle-x", Xangle, true)) 105 Xangle = 0.; 106 if (ValueStorage::getInstance().queryCurrentValue("angle-y", Yangle, true)) 107 Yangle = 0.; 108 if (ValueStorage::getInstance().queryCurrentValue("angle-z", Zangle, true)) 109 Zangle = 0.; 110 RotationMatrix.rotation(Xangle, Yangle, Zangle); 83 111 84 DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms inside a cuboid at " << position << " and extension of " << extension << "." << endl);85 Shape s = translate( stretch(Cuboid(),extension),position);112 DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << position << " and extension of " << extension << "." << endl); 113 Shape s = translate(transform(stretch(Cuboid(),extension),RotationMatrix),position); 86 114 World::getInstance().selectAllAtoms(AtomByShape(s)); 87 return Action::state_ptr(new SelectionAllAtomsInsideCuboidState(selectedAtoms, position, extension ));115 return Action::state_ptr(new SelectionAllAtomsInsideCuboidState(selectedAtoms, position, extension, Xangle, Yangle, Zangle)); 88 116 } 89 117 … … 95 123 World::getInstance().selectAtom(*iter); 96 124 97 return Action::state_ptr( new SelectionAllAtomsInsideCuboidState(state->selectedAtoms, state->position, state->extension));125 return Action::state_ptr(_state); 98 126 } 99 127 100 128 Action::state_ptr SelectionAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){ 101 129 SelectionAllAtomsInsideCuboidState *state = assert_cast<SelectionAllAtomsInsideCuboidState*>(_state.get()); 130 Matrix RotationMatrix; 102 131 103 Shape s = translate(stretch(Cuboid(),state->extension),state->position); 132 RotationMatrix.rotation(state->Xangle, state->Yangle, state->Zangle); 133 Shape s = translate(transform(stretch(Cuboid(),state->extension),RotationMatrix),state->position); 104 134 World::getInstance().selectAllAtoms(AtomByShape(s)); 105 135 106 return Action::state_ptr( new SelectionAllAtomsInsideCuboidState(state->selectedAtoms, state->position, state->extension));136 return Action::state_ptr(_state); 107 137 } 108 138 -
src/Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp
r03c902 r31fb1d 17 17 class SelectionAllAtomsInsideCuboidAction : public Action { 18 18 friend void SelectionAllAtomsInsideCuboid(const Vector &position, const Vector &extension); 19 friend void SelectionAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle); 19 20 20 21 public: -
src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.cpp
r03c902 r31fb1d 20 20 #include "Helpers/Log.hpp" 21 21 #include "Helpers/Verbose.hpp" 22 #include "LinearAlgebra/Matrix.hpp" 22 23 #include "LinearAlgebra/Vector.hpp" 23 24 #include "Shapes/BaseShapes.hpp" … … 40 41 class SelectionNotAllAtomsInsideCuboidState : public ActionState { 41 42 public: 42 SelectionNotAllAtomsInsideCuboidState(std::vector<atom*> _selectedAtoms, const Vector &_position, const Vector &_extension ) :43 SelectionNotAllAtomsInsideCuboidState(std::vector<atom*> _selectedAtoms, const Vector &_position, const Vector &_extension, const double _Xangle, const double _Yangle, const double _Zangle) : 43 44 selectedAtoms(_selectedAtoms), 44 45 position(_position), 45 extension(_extension) 46 extension(_extension), 47 Xangle(_Xangle), 48 Yangle(_Yangle), 49 Zangle(_Zangle) 46 50 {} 47 51 std::vector<atom*> selectedAtoms; 48 52 Vector position; 49 53 Vector extension; 54 double Xangle; 55 double Yangle; 56 double Zangle; 50 57 }; 51 58 … … 65 72 }; 66 73 74 void SelectionNotAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle) { 75 ValueStorage::getInstance().setCurrentValue(SelectionNotAllAtomsInsideCuboidAction::NAME, extension); 76 ValueStorage::getInstance().setCurrentValue("position", position); 77 ValueStorage::getInstance().setCurrentValue("angle-x", Xangle); 78 ValueStorage::getInstance().setCurrentValue("angle-y", Yangle); 79 ValueStorage::getInstance().setCurrentValue("angle-z", Zangle); 80 ActionRegistry::getInstance().getActionByName(SelectionNotAllAtomsInsideCuboidAction::NAME)->call(Action::NonInteractive); 81 }; 82 67 83 Dialog* SelectionNotAllAtomsInsideCuboidAction::fillDialog(Dialog *dialog) { 68 84 ASSERT(dialog,"No Dialog given when filling action dialog"); … … 78 94 Vector position; 79 95 Vector extension; 96 double Xangle = 0.; 97 double Yangle = 0.; 98 double Zangle = 0.; 99 Matrix RotationMatrix; 80 100 81 101 ValueStorage::getInstance().queryCurrentValue("position", position); 82 102 ValueStorage::getInstance().queryCurrentValue(NAME, extension); 103 // check whether a rotation is given. 104 if (ValueStorage::getInstance().queryCurrentValue("angle-x", Xangle, true)) 105 Xangle = 0.; 106 if (ValueStorage::getInstance().queryCurrentValue("angle-y", Yangle, true)) 107 Yangle = 0.; 108 if (ValueStorage::getInstance().queryCurrentValue("angle-z", Zangle, true)) 109 Zangle = 0.; 110 RotationMatrix.rotation(Xangle, Yangle, Zangle); 83 111 84 DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms inside a cuboid at " << position << " and extension of " << extension << "." << endl); 85 Shape s = translate(stretch(Cuboid(),extension),position); 112 DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << position << " and extension of " << extension << "." << endl); 113 Shape s = translate(transform(stretch(Cuboid(),extension),RotationMatrix),position); 114 86 115 World::getInstance().unselectAllAtoms(AtomByShape(s)); 87 return Action::state_ptr(new SelectionNotAllAtomsInsideCuboidState(selectedAtoms, position, extension ));116 return Action::state_ptr(new SelectionNotAllAtomsInsideCuboidState(selectedAtoms, position, extension, Xangle, Yangle, Zangle)); 88 117 } 89 118 … … 95 124 World::getInstance().selectAtom(*iter); 96 125 97 return Action::state_ptr( new SelectionNotAllAtomsInsideCuboidState(state->selectedAtoms, state->position, state->extension));126 return Action::state_ptr(_state); 98 127 } 99 128 100 129 Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){ 101 130 SelectionNotAllAtomsInsideCuboidState *state = assert_cast<SelectionNotAllAtomsInsideCuboidState*>(_state.get()); 131 Matrix RotationMatrix; 102 132 103 Shape s = translate(stretch(Cuboid(),state->extension),state->position); 133 RotationMatrix.rotation(state->Xangle, state->Yangle, state->Zangle); 134 Shape s = translate(transform(stretch(Cuboid(),state->extension),RotationMatrix),state->position); 104 135 World::getInstance().unselectAllAtoms(AtomByShape(s)); 105 136 106 return Action::state_ptr( new SelectionNotAllAtomsInsideCuboidState(state->selectedAtoms, state->position, state->extension));137 return Action::state_ptr(_state); 107 138 } 108 139 -
src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp
r03c902 r31fb1d 17 17 class SelectionNotAllAtomsInsideCuboidAction : public Action { 18 18 friend void SelectionNotAllAtomsInsideCuboid(const Vector &position, const Vector &extension); 19 friend void SelectionNotAllAtomsInsideCuboid(const Vector &position, const Vector &extension, const double Xangle, const double Yangle, const double Zangle); 19 20 20 21 public: -
src/LinearAlgebra/Matrix.cpp
r03c902 r31fb1d 115 115 } 116 116 117 void Matrix::rotation(const double x, const double y, const double z) 118 { 119 set(0,0, cos(y)*cos(z)); 120 set(0,1, cos(z)*sin(x)*sin(y) - cos(x)*sin(z)); 121 set(0,2, cos(x)*cos(z)*sin(y) + sin(x) * sin(z)); 122 set(1,0, cos(y)*sin(z)); 123 set(1,1, cos(x)*cos(z) + sin(x)*sin(y)*sin(z)); 124 set(1,2, -cos(z)*sin(x) + cos(x)*sin(y)*sin(z)); 125 set(2,0, -sin(y)); 126 set(2,1, cos(y)*sin(x)); 127 set(2,2, cos(x)*cos(y)); 128 } 129 117 130 Matrix &Matrix::operator=(const Matrix &src){ 118 131 if(&src!=this){ … … 220 233 221 234 222 voidMatrix::transpose()235 Matrix &Matrix::transpose() 223 236 { 224 237 double tmp; … … 226 239 for (int j=i+1;j<NDIM;j++) { 227 240 tmp = at(j,i); 241 at(j,i) = at(i,j); 228 242 at(i,j) = tmp; 229 at(j,i) = tmp;230 }243 } 244 return *this; 231 245 } 232 246 -
src/LinearAlgebra/Matrix.hpp
r03c902 r31fb1d 54 54 */ 55 55 void zero(); 56 57 /** 58 * Sets all matrix corresponding to a rotation matrix, 59 * first around the x-, then the y-, finally the z-axis 60 * with given angles. 61 */ 62 void rotation(const double x, const double y, const double z); 56 63 57 64 /** … … 113 120 */ 114 121 Matrix transpose() const; 115 voidtranspose();122 Matrix &transpose(); 116 123 117 124 // operators -
src/unittests/MatrixUnittest.cpp
r03c902 r31fb1d 14 14 #include <cppunit/extensions/TestFactoryRegistry.h> 15 15 #include <cppunit/ui/text/TestRunner.h> 16 17 #include <cmath> 16 18 17 19 #include "MatrixUnittest.hpp" … … 156 158 } 157 159 } 160 } 161 162 void MatrixUnittest::TransposeTest(){ 163 Matrix res; 164 165 // transpose of unit is unit 166 res.one(); 167 (const Matrix)res.transpose(); 168 CPPUNIT_ASSERT_EQUAL(res,*one); 169 170 // transpose of transpose is same matrix 171 res.zero(); 172 res.set(2,2, 1.); 173 CPPUNIT_ASSERT_EQUAL(res.transpose().transpose(),res); 158 174 } 159 175 … … 230 246 } 231 247 248 void MatrixUnittest::RotationTest(){ 249 Matrix res; 250 Matrix inverse; 251 252 // zero rotation angles yields unity matrix 253 res.rotation(0,0,0); 254 CPPUNIT_ASSERT_EQUAL(*one, res); 255 256 // arbitrary rotation matrix has det = 1 257 res.rotation(M_PI/3.,1.,M_PI/7.); 258 CPPUNIT_ASSERT(fabs(fabs(res.determinant()) -1.) < MYEPSILON); 259 260 // inverse is rotation matrix with negative angles 261 res.rotation(M_PI/3.,0.,0.); 262 inverse.rotation(-M_PI/3.,0.,0.); 263 CPPUNIT_ASSERT_EQUAL(*one, res * inverse); 264 265 // ... or transposed 266 res.rotation(M_PI/3.,0.,0.); 267 CPPUNIT_ASSERT_EQUAL(inverse, ((const Matrix) res).transpose()); 268 } 232 269 233 270 void MatrixUnittest::InvertTest(){ -
src/unittests/MatrixUnittest.hpp
r03c902 r31fb1d 19 19 CPPUNIT_TEST ( VectorTest ); 20 20 CPPUNIT_TEST ( OperationTest ); 21 CPPUNIT_TEST ( TransposeTest ); 22 CPPUNIT_TEST ( RotationTest ); 21 23 CPPUNIT_TEST ( InvertTest ); 22 24 CPPUNIT_TEST ( DeterminantTest ); … … 31 33 void VectorTest(); 32 34 void OperationTest(); 35 void TransposeTest(); 36 void RotationTest(); 33 37 void InvertTest(); 34 38 void DeterminantTest();
Note:
See TracChangeset
for help on using the changeset viewer.