| 297 |
|
frameData.volume = vol; |
| 298 |
|
} |
| 299 |
|
|
| 300 |
+ |
|
| 301 |
|
/** Wrap a vector according to periodic boundary conditions */ |
| 302 |
|
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]); |
| 303 |
|
|
| 304 |
< |
if( !frameData.orthoRhombic ) |
| 305 |
< |
pos = frameData.hmat * scaled; |
| 306 |
< |
else { |
| 307 |
< |
|
| 304 |
> |
if( !frameData.orthoRhombic ) { |
| 305 |
> |
Vector3d scaled = frameData.invHmat * pos; |
| 306 |
> |
for (int i = 0; i < 3; i++) { |
| 307 |
> |
scaled[i] -= roundMe( scaled[i] ); |
| 308 |
> |
} |
| 309 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
| 310 |
< |
for (int i=0; i<3; i++) { |
| 311 |
< |
pos[i] = scaled[i] * frameData.hmat(i, i); |
| 312 |
< |
} |
| 310 |
> |
pos = frameData.hmat * scaled; |
| 311 |
> |
} else { |
| 312 |
> |
RealType scaled; |
| 313 |
> |
for (int i=0; i<3; i++) { |
| 314 |
> |
scaled = pos[i] * frameData.invHmat(i,i); |
| 315 |
> |
scaled -= roundMe( scaled ); |
| 316 |
> |
pos[i] = scaled * frameData.hmat(i,i); |
| 317 |
> |
} |
| 318 |
|
} |
| 319 |
|
} |
| 320 |
|
|