--- branches/development/src/brains/Snapshot.cpp 2010/07/09 23:08:25 1465 +++ branches/development/src/brains/Snapshot.cpp 2011/05/25 16:20:37 1568 @@ -59,7 +59,6 @@ namespace OpenMD { hmat_ = m; invHmat_ = hmat_.inverse(); - //prepare fortran Hmat RealType fortranHmat[9]; RealType fortranInvHmat[9]; @@ -115,49 +114,43 @@ namespace OpenMD { } //notify fortran simulation box has changed - setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); + // setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); } void Snapshot::wrapVector(Vector3d& pos) { + + Vector3d scaled = scaleVector(pos); + + for (int i = 0; i < 3; i++) + scaled[i] -= roundMe(scaled[i]); - int i; - Vector3d scaled; + if( !orthoRhombic_ ) + pos = hmat_ * scaled; + else { - 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 - pos = hmat_ * scaled; + for (int i=0; i<3; i++) { + pos[i] = scaled[i] * hmat_(i, i); + } + } + } - } else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element + inline Vector3d Snapshot::scaleVector(Vector3d& pos) { - // 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]); - } + Vector3d scaled; - // calc the wrapped real coordinates from the wrapped scaled coordinates - for (i=0; i<3; i++) { - pos[i] = scaled[i] * hmat_(i, i); - } - + 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"); @@ -184,6 +177,5 @@ namespace OpenMD { } return COMw_; } - }