Calculating the x, y and z distances between two molecules - AMBER (Molecular Dynamics) I am interested in calculating the x,y and z distance between two molecules over a given simulation time. I know how to calculate the total (r) distance between them, but I want the distance between them along all three dimensions.

For the total distance, cpptraj can be used as:

parm prmtop-file
trajin netcdf-file
distance DIST :1-4@heavy-atoms-from-molecule-1 :5-8@heavy-atoms-from-molecule-2 out dist.out
run
quit


But like I said before, I do not want the r-distance. Is there anyway to calculate the x,y and z-distances in cpptraj? If not, what other alternatives do I have?
I ended up realizing that if you run:

parm prmtop-file
trajin netcdf-file
vector v0 :1-4@heavy-atoms-from-molecule-1 :5-8@heavy-atoms-from-molecule-2 out v0.out magnitude
run
quit


You will get the total distance as well as x, y and z distances between your two molecules. The output file will contain 8 columns. The AMBER manual states that they are identified as follows:

Frame | x-Vector-Coordinate | y-Vector-Coordinate | z-Vector-Coordinate | x-Origin-Coordinate | y-Origin-Coordinate | z-Origin-Coordinate | Magnitude

The vector coordinates are your x, y and z distances. Magnitude is the total distance.

Decided to share this as someone might run into the same problem one day.