- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
r0430e3 r6e5084 10 10 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 11 11 #include "Actions/ActionRegistry.hpp" 12 #include "Helpers/Log.hpp" 13 #include "Helpers/Verbose.hpp" 14 #include "LinearAlgebra/Matrix.hpp" 15 #include "LinearAlgebra/Vector.hpp" 16 #include "element.hpp" 12 17 #include "molecule.hpp" 13 #include "log.hpp"14 #include "verbose.hpp"15 18 16 19 #include <iostream> … … 21 24 #include "UIElements/UIFactory.hpp" 22 25 #include "UIElements/Dialog.hpp" 23 #include " UIElements/ValueStorage.hpp"26 #include "Actions/ValueStorage.hpp" 24 27 25 28 const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system"; … … 36 39 }; 37 40 38 Dialog* AnalysisPrincipalAxisSystemAction:: createDialog() {39 Dialog *dialog = UIFactory::getInstance().makeDialog();41 Dialog* AnalysisPrincipalAxisSystemAction::fillDialog(Dialog *dialog) { 42 ASSERT(dialog,"No Dialog given when filling action dialog"); 40 43 41 44 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); … … 46 49 Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() { 47 50 molecule *mol = NULL; 51 Matrix InertiaTensor; 48 52 49 53 ValueStorage::getInstance().queryCurrentValue(NAME, mol); … … 51 55 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 52 56 molecule *mol = iter->second; 53 mol->PrincipalAxisSystem(false); 57 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 58 59 // reset inertia tensor 60 InertiaTensor.zero(); 61 62 // sum up inertia tensor 63 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 64 Vector x = (*iter)->x; 65 x -= *CenterOfGravity; 66 InertiaTensor.at(0,0) += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 67 InertiaTensor.at(0,1) += (*iter)->type->mass*(-x[0]*x[1]); 68 InertiaTensor.at(0,2) += (*iter)->type->mass*(-x[0]*x[2]); 69 InertiaTensor.at(1,0) += (*iter)->type->mass*(-x[1]*x[0]); 70 InertiaTensor.at(1,1) += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 71 InertiaTensor.at(1,2) += (*iter)->type->mass*(-x[1]*x[2]); 72 InertiaTensor.at(2,0) += (*iter)->type->mass*(-x[2]*x[0]); 73 InertiaTensor.at(2,1) += (*iter)->type->mass*(-x[2]*x[1]); 74 InertiaTensor.at(2,2) += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 75 } 76 // print InertiaTensor for debugging 77 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl); 54 78 } 55 79 return Action::success;
Note:
See TracChangeset
for help on using the changeset viewer.
