Coordinate Systems

From Jmol
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.

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

Jmol uses the 3D coordinates for nearly all the operations. Note also that, when the model is rotated or translated (either by mouse action or by commands) the coordinate system and axes move together with the model. That is, position of the model in the 3D coordinate system is always the same; it's just the viewpoint that changes (and, accordingly, the screen coordinates do change with any rotation, translation or zoom).

Commands that use each coordinate system

3D coordinates


Labels are attached to individual atoms, therefore they are linked to the x,y,z coordinates. Command syntax


Measurements are also attached to 2, 3 or 4 atoms and so work with the 3D x,y,z coordinates. Command syntax

set echo (3D variety)

The special syntax for the echo command that provides 3D coordinates of a point to which the echo will be attached (and hence the echo will rotate and translate with the model). Command syntax
Example: set echo id myFirstEcho {1.2 -4.0 1.1}; echo This is the position in 3D;

Screen coordinates

set echo (2D variety)

The more standard syntax of the echo command positions text with reference to the screen 2D space (hence the text does not move when the model is rotated or translated). Command syntax
set echo top center; echo This is a title;
set echo id mySecondEcho 100 50; echo This is at 100,50 pixels;
set echo id my3rdEcho 10% 90%; echo This is near top left;

Retrieving 3D coordinates

When a model file is loaded, the position of the origin and the orientation of the x,y,z axes are usually:

  • origin at the center of the Jmol screen
  • X axis horizontally to the right
  • Y axis vertically upwards
  • Z axis normal to the screen and to the front (towards the observer)

This may be different if the file contains some orientation instructions.

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;