| 299 |
|
|
| 300 |
|
/** Wrap a vector according to periodic boundary conditions */ |
| 301 |
|
void Snapshot::wrapVector(Vector3d& pos) { |
| 302 |
– |
|
| 303 |
– |
Vector3d scaled = scaleVector(pos); |
| 304 |
– |
|
| 305 |
– |
for (int i = 0; i < 3; i++) |
| 306 |
– |
scaled[i] -= roundMe(scaled[i]); |
| 302 |
|
|
| 303 |
< |
if( !frameData.orthoRhombic ) |
| 304 |
< |
pos = frameData.hmat * scaled; |
| 305 |
< |
else { |
| 306 |
< |
|
| 303 |
> |
if( !frameData.orthoRhombic ) { |
| 304 |
> |
Vector3d scaled = frameData.invHmat * pos; |
| 305 |
> |
for (int i = 0; i < 3; i++) |
| 306 |
> |
scaled[i] -= roundMe(scaled[i]); |
| 307 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
| 308 |
+ |
pos = frameData.hmat * scaled; |
| 309 |
+ |
} else { |
| 310 |
+ |
// calc the scaled coordinates. |
| 311 |
+ |
RealType scaled; |
| 312 |
|
for (int i=0; i<3; i++) { |
| 313 |
< |
pos[i] = scaled[i] * frameData.hmat(i, i); |
| 314 |
< |
} |
| 313 |
> |
scaled = pos[i] * frameData.invHmat(i, i); |
| 314 |
> |
scaled -= roundMe(scaled); |
| 315 |
> |
pos[i] = scaled * frameData.hmat(i, i); |
| 316 |
> |
} |
| 317 |
|
} |
| 318 |
|
} |
| 319 |
|
|
| 320 |
+ |
|
| 321 |
|
/** Scaling a vector to multiples of the periodic box */ |
| 322 |
|
inline Vector3d Snapshot::scaleVector(Vector3d& pos) { |
| 323 |
|
|