- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
r6e5084 r0430e3 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"17 12 #include "molecule.hpp" 13 #include "log.hpp" 14 #include "verbose.hpp" 18 15 19 16 #include <iostream> … … 24 21 #include "UIElements/UIFactory.hpp" 25 22 #include "UIElements/Dialog.hpp" 26 #include " Actions/ValueStorage.hpp"23 #include "UIElements/ValueStorage.hpp" 27 24 28 25 const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system"; … … 39 36 }; 40 37 41 Dialog* AnalysisPrincipalAxisSystemAction:: fillDialog(Dialog *dialog) {42 ASSERT(dialog,"No Dialog given when filling action dialog");38 Dialog* AnalysisPrincipalAxisSystemAction::createDialog() { 39 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 40 44 41 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); … … 49 46 Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() { 50 47 molecule *mol = NULL; 51 Matrix InertiaTensor;52 48 53 49 ValueStorage::getInstance().queryCurrentValue(NAME, mol); … … 55 51 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 56 52 molecule *mol = iter->second; 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); 53 mol->PrincipalAxisSystem(false); 78 54 } 79 55 return Action::success;
Note:
See TracChangeset
for help on using the changeset viewer.
