--- branches/development/src/brains/Snapshot.cpp 2011/04/27 21:49:59 1550 +++ branches/development/src/brains/Snapshot.cpp 2011/05/12 17:00:14 1562 @@ -118,46 +118,39 @@ namespace OpenMD { } - void Snapshot::wrapVector(Vector3d& pos) { + inline void Snapshot::wrapVector(Vector3d& pos) { + + Vector3d scaled = scaleVector(pos); - int i; - Vector3d scaled; + for (int i = 0; i < 3; i++) + scaled[i] -= roundMe(scaled[i]); - if( !orthoRhombic_ ){ - - // calc the scaled coordinates. - scaled = invHmat_* pos; - - // wrap the scaled coordinates - for (i = 0; i < 3; ++i) { - scaled[i] -= roundMe(scaled[i]); - } - - // calc the wrapped real coordinates from the wrapped scaled coordinates + if( !orthoRhombic_ ) pos = hmat_ * scaled; + else { - } else { - - // if it is orthoRhombic, we could improve efficiency by only - // caculating the diagonal element - - // calc the scaled coordinates. - for (i=0; i<3; i++) { - scaled[i] = pos[i] * invHmat_(i, i); - } - - // wrap the scaled coordinates - for (i = 0; i < 3; ++i) { - scaled[i] -= roundMe(scaled[i]); - } - // calc the wrapped real coordinates from the wrapped scaled coordinates - for (i=0; i<3; i++) { + for (int i=0; i<3; i++) { pos[i] = scaled[i] * hmat_(i, i); } } } + inline Vector3d Snapshot::scaleVector(Vector3d& pos) { + + Vector3d scaled; + + if( !orthoRhombic_ ) + scaled = invHmat_* pos; + else { + // calc the scaled coordinates. + for (int i=0; i<3; i++) + scaled[i] = pos[i] * invHmat_(i, i); + } + + return scaled; + } + Vector3d Snapshot::getCOM() { if( !hasCOM_ ) { sprintf( painCave.errMsg, "COM was requested before COM was computed!\n");