| 164 |  | } | 
| 165 |  |  | 
| 166 |  | // Moment of Inertia calculation | 
| 167 | < | Mat3x3d Itmp(0.0); | 
| 168 | < |  | 
| 167 | > | Mat3x3d Itmp(0.0); | 
| 168 |  | for (std::size_t i = 0; i < atoms_.size(); i++) { | 
| 169 | + | Mat3x3d IAtom(0.0); | 
| 170 |  | mtmp = atoms_[i]->getMass(); | 
| 171 | < | Itmp -= outProduct(refCoords_[i], refCoords_[i]) * mtmp; | 
| 171 | > | IAtom -= outProduct(refCoords_[i], refCoords_[i]) * mtmp; | 
| 172 |  | double r2 = refCoords_[i].lengthSquare(); | 
| 173 | < | Itmp(0, 0) += mtmp * r2; | 
| 174 | < | Itmp(1, 1) += mtmp * r2; | 
| 175 | < | Itmp(2, 2) += mtmp * r2; | 
| 176 | < | } | 
| 177 | < |  | 
| 178 | < | //project the inertial moment of directional atoms into this rigid body | 
| 179 | < | for (std::size_t i = 0; i < atoms_.size(); i++) { | 
| 173 | > | IAtom(0, 0) += mtmp * r2; | 
| 174 | > | IAtom(1, 1) += mtmp * r2; | 
| 175 | > | IAtom(2, 2) += mtmp * r2; | 
| 176 | > | Itmp += IAtom; | 
| 177 | > |  | 
| 178 | > | //project the inertial moment of directional atoms into this rigid body | 
| 179 |  | if (atoms_[i]->isDirectional()) { | 
| 180 | < | RectMatrix<double, 3, 3> Iproject = refOrients_[i].transpose() * atoms_[i]->getI(); | 
| 181 | < | Itmp(0, 0) += Iproject(0, 0); | 
| 183 | < | Itmp(1, 1) += Iproject(1, 1); | 
| 184 | < | Itmp(2, 2) += Iproject(2, 2); | 
| 185 | < | } | 
| 180 | > | Itmp += refOrients_[i].transpose() * atoms_[i]->getI() * refOrients_[i]; | 
| 181 | > | } | 
| 182 |  | } | 
| 183 |  |  | 
| 184 |  | //diagonalize | 
| 269 |  | if (atoms_[i]->isDirectional()) { | 
| 270 |  |  | 
| 271 |  | dAtom = (DirectionalAtom *) atoms_[i]; | 
| 272 | < | dAtom->setA(a * refOrients_[i]); | 
| 277 | < | //dAtom->rotateBy( A ); | 
| 272 | > | dAtom->setA(refOrients_[i] * a); | 
| 273 |  | } | 
| 274 |  |  | 
| 275 |  | } | 
| 296 |  | if (atoms_[i]->isDirectional()) { | 
| 297 |  |  | 
| 298 |  | dAtom = (DirectionalAtom *) atoms_[i]; | 
| 299 | < | dAtom->setA(a * refOrients_[i], frame); | 
| 299 | > | dAtom->setA(refOrients_[i] * a, frame); | 
| 300 |  | } | 
| 301 |  |  | 
| 302 |  | } |