- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp
rb8463f r833b15 62 62 } 63 63 64 // check whether Axis is valid65 if (params.Axis.get().IsZero()) {66 STATUS("Rotation Axis must not be zero.");67 return Action::failure;68 }69 70 // convert from degrees to radian71 const double angle_radian = params.angle.get() * M_PI/180.;72 73 64 // go through all selected molecules 74 65 BOOST_FOREACH(molecule *mol, selectedMolecules) { 66 // check whether Axis is valid 67 if (params.Axis.get().IsZero()) { 68 STATUS("Rotation Axis must not be zero."); 69 return Action::failure; 70 } 71 72 // convert from degrees to radian 73 params.angle.set(params.angle.get() * M_PI/180.); 74 75 75 // Creation Line that is the rotation axis 76 76 const Vector CenterOfGravity = mol->DetermineCenterOfGravity(); 77 LOG( 3, "DEBUG:Center of gravity is " << CenterOfGravity << ".");77 LOG(0, "Center of gravity is " << CenterOfGravity << "."); 78 78 Line RotationAxis(CenterOfGravity, params.Axis.get()); 79 LOG( 2, "DEBUG: Rotate " << mol->getName() << " around self by " << angle_radian<< " radian around axis " << RotationAxis << ".");79 LOG(0, "Rotate " << mol->getName() << " around self by " << params.angle.get() << " radian around axis " << RotationAxis << "."); 80 80 81 81 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 82 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), angle_radian));82 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), params.angle.get())); 83 83 } 84 LOG( 2, "DEBUG: Rotatating of " << mol->getName() << "done.");84 LOG(0, "done."); 85 85 } 86 86 … … 91 91 MoleculeRotateAroundSelfByAngleState *state = assert_cast<MoleculeRotateAroundSelfByAngleState*>(_state.get()); 92 92 93 // convert from degrees to radian94 const double angle_radian = -state->params.angle.get() * M_PI/180.;95 96 93 BOOST_FOREACH(molecule *mol, state->selectedMolecules) { 97 94 const Vector CenterOfGravity = mol->DetermineCenterOfGravity(); 98 95 LOG(0, "Center of gravity is " <<CenterOfGravity << "."); 99 96 Line RotationAxis(CenterOfGravity, state->params.Axis.get()); 100 LOG(0, "Rotate " << mol->getName() << " around self by " << angle_radian<< " radian around axis " << RotationAxis << ".");97 LOG(0, "Rotate " << mol->getName() << " around self by " << -state->params.angle.get() << " radian around axis " << RotationAxis << "."); 101 98 102 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) 103 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), angle_radian)); 99 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 100 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), -state->params.angle.get())); 101 } 104 102 } 105 103 … … 110 108 MoleculeRotateAroundSelfByAngleState *state = assert_cast<MoleculeRotateAroundSelfByAngleState*>(_state.get()); 111 109 112 // convert from degrees to radian113 const double angle_radian = state->params.angle.get() * M_PI/180.;114 115 110 BOOST_FOREACH(molecule *mol, state->selectedMolecules) { 116 111 const Vector CenterOfGravity = mol->DetermineCenterOfGravity(); 117 112 LOG(0, "Center of gravity is " << CenterOfGravity << "."); 118 113 Line RotationAxis(CenterOfGravity, state->params.Axis.get()); 119 LOG(0, "Rotate " << mol->getName() << " around self by " << angle_radian<< " radian around axis " << RotationAxis << ".");114 LOG(0, "Rotate " << mol->getName() << " around self by " << state->params.angle.get() << " radian around axis " << RotationAxis << "."); 120 115 121 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) 122 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), angle_radian)); 116 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 117 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), state->params.angle.get())); 118 } 123 119 } 124 120
Note:
See TracChangeset
for help on using the changeset viewer.