--- trunk/OOPSE/libmdtools/Molecule.cpp 2003/04/03 20:19:50 446 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2003/04/07 16:56:38 468 @@ -120,7 +120,7 @@ void Molecule::printMe( void ){ } } -void Molecule::moveCOM(double* delta){ +void Molecule::moveCOM(double delta[3]){ double x, y, z; int i; @@ -138,7 +138,7 @@ void Molecule::moveCOM(double* delta){ } } -double* Molecule::getCOM() { +void Molecule::getCOM( double COM[3] ) { double mass, mtot; int i; @@ -164,5 +164,32 @@ double* Molecule::getCOM() { COM[1] /= mtot; COM[2] /= mtot; - return COM; } + +void Molecule::getCOMvel( double mtot, double COMvel[3] ) { + + double mass; + int i; + + COMvel[0] = 0.0; + COMvel[1] = 0.0; + COMvel[2] = 0.0; + mtot = 0.0; + + for (i=0; i < nAtoms; i++) { + if (myAtoms[i] != NULL) { + + mass = myAtoms[i]->getMass(); + mtot += mass; + COMvel[0] += myAtoms[i]->get_vx() * mass; + COMvel[1] += myAtoms[i]->get_vy() * mass; + COMvel[2] += myAtoms[i]->get_vz() * mass; + + } + } + + COMvel[0] /= mtot; + COMvel[1] /= mtot; + COMvel[2] /= mtot; + +}