Jmol/JSmol interactive scripting documentation



Search View Full Database Index

rotate 

The rotate and spin commands allow single angle rotation or continued rotation (spinning) in one of two specific frames, effectively changing the "camera" position. These frames include the standard "fixed" applet window frame and the internal "molecular" model frame (the axes in the data file). Coordinate specifications for the rotation can be given several ways, including absolute coordinate positions set in braces as {x, y, z}, the geometric center of a subset of atoms in the model specified in an atom set in parentheses, for example {atomno < 10 and not oxygen}, or the geometric center of a previously defined draw object, indicated by the drawing object name preceded by a dollar sign (for example, $line1). In addition, rotation may be specified to be around six standard axes (x, y, z, -x, -y, and -z) as well as several other options. The keyword MOLECULAR may be necessary for explicit model rotation about the internal molecular axes. Defaults are allowed. The default axis for spinining or rotating is the y (vertical) axis; the default angle of rotation is 10 degrees; the default rotation rate is a slow spin of 10 degrees per second. Options may be given in any order and include:
  By itself, the rotate command rotates 10 degrees around the y (vertical) axis in a counterclockwise fashion.
x, y, z, -x, -y, -z Rotation about one of the six standard axes. The implied axes are the axes of the window, not the molecule.
x.x When one number is given, that number indicates for a simple rotation command such as ROTATE x 30 the number of degrees for a rotation, either positive (right-hand rotation) or negative (left-hand rotation). For a spin, for example using ROTATE SPIN y 10, this number indicates the rate of spin in degrees per second. For the TRANSLATION option, this is the number of Angstroms total for the translation.
x.x y.y Two numbers, for example, ROTATE 30 10 specifies a finite animated rotation or translation. The first number is as for a single number (above). The second number has an effect that depends upon its sign. If the two numbers are the same sign, as in this example, the second number indicates the rate of spinning in degrees per second (or, for the TRANSLATION option, linear movement in angstroms per second). If the second number is opposite the sign of the first number, as in ROTATE 30 -20 or ROTATE -30 30, then the specified finite rotation or translation is carried out over |y.y| seconds. In this case, the value of set waitformoveto determines whether the script waits for the rotation or translation to complete or continues while that process occurs independently.
{atom expression or point} {atom expression or point} Rotation about an axis pointing from the first point to the second in right-hand direction. For example, rotate {0 0 0} {1 0 0} 10 is the same as rotate x 10, and spin {atomno=1} {atomno=2} spins the model around the axis connecting these two atoms.
$drawID the two atoms desired for rotation can be defined based on a drawn object such as a line or vector by specifying the ID of that drawn object.
{3x3 matrix} A 3x3 matrix can be used to specify the axis and angle of a rotation; MOLECULAR is implied.
{4x4 matrix} A 4x4 matrix can be used to specify a rotation axis and angle along with a translation; MOLECULAR is implied.
AXISANGLE {x y z} Rotation about an axis defined as a vector from the origin {0,0,0} to the specified {x,y,z} coordinate.
AXISANGLE {x y z theta} Rotation about an axis through {0 0 0} and {x y z} by the specified number of degrees.
HELIX For any operation involving a translation (4x4 matrix, COMPARE, SYMOP, or TRANSLATE options) carries out the rotation about the optimum helical path.
INTERNAL Same as MOLECULAR.
MOLECULAR In the case of simple axes such as x or y, indicates that the axis is defined in terms of molecular coordinates.
QUATERNION {x y z w} Rotation about an axis defined by the specified quaternion in the form of a four-vector. For example, to reset the model to the original orientation without changing the zoom, one can use rotate QUATERNION @{ !quaternion(script("show rotation")) }. The keyword QUATERNION is optional.
SELECTED Rotate only the currently selected atoms.
SPIN Provide an animation of the rotation. Implied when two decimals -- a number of degrees and a rate -- are given.
TRANSLATE Add a translation to the animation (providing a screw-like motion) MOLECULAR and SELECTED are implied. If only one point is specified, then this command allows for an animation of a movement of the selected set of atoms along the vector connecting {0 0 0} and that point. In that case, the extent is in Angstroms and rate is in AngstromsPerSecond; otherwise, as for other rotations, extent is in degrees and rate is in degreesPerSecond.


 rotate BEST

Rotates the model to a calculated "best" orientation for viewing the selected atoms, such that those atoms' containing box is thinnest along the line of sight (z), and widest horizontally (x). With ROTATE SELECTED BEST, atom positions are actually changed; otherwise only the viewpoint is changed.

 rotate BRANCH {atom1} {atom2}

Rotates the atoms that are in the molecular branch containing {atom 2} but not {atom 1} about the axis connecting these two atoms. For example, to spin a methyl group having carbon atom C12 about its connected atom by 360 degrees at a rate of 30 degrees per second, one might use spin BRANCH {_C and connected(C12)} {C12} 360 30. If fewer than two numbers are given, rotation will continue until spin OFF or another spin command is issued. Attempting to rotate around a bond within a ring may lead to undesired results.

 rotate BRANCH @list nSeconds

A special rotate BRANCH option takes as its parameter a list of n dihedrals with starting and target angles. All dihedrals are rotated concurrently over nSeconds time. The array list has 6n elements, a sequence of for each dihedral of i1, i2, i3, i4, v1, v2, where i1, i2, i3, and i4 are atom indices involved in a dihedral, in order, and v1 and v2 are the initial and final dihedral angles for that set of atoms. See also the compare BONDS option, which uses this BRANCH option internally.

 rotate COMPARE {atomset} [atom-expression-or-coordinate]

A variation of the compare command. For atoms, determines the best-fit correlation between atoms in atomSet1 and atoms in atomSet2 and then rotates and/or translates atomSet1 to align with atomSet2. The two atom sets must have the same number of atoms and must have a direct 1:1 correlation of atoms. (For a more general comparison, see the compare command. An array of points, such as @{ {2.1}.xyz.all} may take the place of the second atom set. This allows, for example, saving of a set of coordinates with tempCoords = {2.1}.xyz.all and restoring of those coordinates with ROTATE COMPARE {2.1} @{tempCoords} some time after a selected atom rotation.

 rotate SYMOP n

Carry out the symmetry operation number n (or, if n is a negative number, the reverse of that operation) on the currently selected atoms.



Examples:
# set to final state
moveto 0.0 { -46 -870 492 142.18} 300.0 0.0 0.0 {61.260506 38.7915 44.659} 50.97134 {0.0 0.0 0.0} 281.9351 50.269466 50.0
qfinal = quaternion(script("show rotation"))
# set to initial state
moveto 0.0 { -142 866 480 107.35} 100.0 0.0 0.0 {61.260506 38.7915 44.659} 50.97134 {0.0 0.0 0.0} 8.481314 102.86942 50.0;
qinitial = quaternion(script("show rotation"))
# calculate steps
dq = qfinal / qinitial / 20
# now loop and save
write image "image0.jpg"
for (i = 1; i <= 20; i = i+1) {
    rotate quaternion @dq
    f = "image"+i+".jpg"
    write image @f
}


See also:

undefined



top search index

Index (full)


rotate 
rotate BEST
rotate BRANCH {atom1} {atom2}
rotate BRANCH @list nSeconds
rotate COMPARE {atomset} [atom-expression-or-coordinate]
rotate SYMOP n


last updated: May 04, 2025 11:01:10

html

xml docbook