Coordinate Systems

From Jmol
Revision as of 18:44, 23 August 2018 by AngelHerraez (talk | contribs) (documenting screen coordinates)
Jump to navigation Jump to search

Coordinate systems in Jmol

When a file is loaded, the model contains a 3D space system of coordinates and the values of x,y,z for every atom. This coordinate system is inherent to the model. If you load several models, each one brings its own coordinates, so you will usually see both models positioned very far apart, or sometimes overlapping.

Jmol uses this 3D coordinates for all the operations.

Some commands, however, refer to a 2D space, the projection that the observer sees; these are the "screen coordinates".

Retrieving 3D coordinates

The position of the origin and the orientation of the x,y,z axes may be anyone with respect to the viewer (i.e. the screen display) when a model file is loaded. The command axes on will let you check those.

Examples of how to check the coordinates of an atom: (p1 is a variable used to hold the values and print allows to see its value)

p1 = {atomNo=6}.xyz;
print p1.x;
print p1.y;
print p1.z;

p1 = {atomNo=6}.x;
print p1;
p1 = {atomNo=6}.y;
print p1;
p1 = {atomNo=6}.z;
print p1;

Retrieving screen coordinates

Screen coordinates sx,sy,sz are defined as:

  • sx from the left border
  • sy from the bottom border
  • sz from the front (small sz for positions at the front, near the observer; large sz for positions at the rear, far from the observer)
p2 = {atomNo=6}.sx;
print p2;
p2 = {atomNo=6}.sy;
print p2;
p2 = {atomNo=6}.sz;
print p2;

Converting between 3D coordinates and screen coordinates

This gives the screen coordinates {sx, sy, sz} corresponding to the 3D coordinates {x, y, z}:

point({x,y,z}, true);

Examples of use:

p3 = point( {atomNo=6}, true)
print p3.x;  // same as print {atomNo=6}.sx;
print p3.y;  // same as print {atomNo=6}.sy;

p3 = point( {4.65, -9.80, 1.21}, true)
print p3.x;
print p3.y;

And this does the opposite conversion: gives the 3D coordinates {x, y, z} corresponding to the screen coordinates {sx, sy, sz}:

point({sx,sy,sz}, false);

Example of use:

p4 = point( {124, -230, 5000}, false)
print p4.x;
print p4.y;

Contributors

AngelHerraez