How It Works

MoveTo uses a series of javascript functions and Chime script commands which are located in the Head section of the web page, or as a separate script.js file which is called from the document Head. To start a MoveTo, you call the the MoveTo javascript function with the nine parameters shown below.  You can call the MoveTo function using a form button or with a Chime script using the javascript command.  In this web page, the MoveTo button is a form button.  We have found the calling a javascript function with a Chime button causes problems with Mac computers running Netscape.  Pushing the MoveTo button calls the javascript function below.

MoveTo(XRot,YRot,ZRot,Zoom,XTrans,YTrans,Time,FPS,Max Accel)

MoveTo(-61.5,-14.15,25.3,325,18,-10,3,30,5)

The first six parameter are the rotations, zoom and translations needed to generate the desired image starting from the default orientation after a reset command (rotations done in the z, y, x order). Note that these are not the move parameters that will be executed, but rather they will be used later to calculate the necessary parameters. The last three parameters are the total time (in seconds), the number of frames per second, and the maximum acceleration for the animation, as described in the Chime move script command. All parameters are required in MoveTo.

There are several ways to determine the MoveTo parameters needed to create your desired view.  One option is to create the view you want on the screen, right-click the Chime image, select Copy Chime Script under the Edit menu option and paste the result into a text editor. The rotation, zoom and translation commands will be near the beginning the the script. Another option is to execute a view show view Chime script command and have the output printed onto a textbox on the screen. If a translation or rotation parameter is not returned, use the default parameter zero. If the zoom parameter is not returned, use the default parameter 100.  The easiest option may be to use our MoveTo utility page, which does this for you automatically.

The MoveTo javascript function is very simple.  First it toggles a variable to true so the program knows it is in the process of executing a MoveTo command.  Then it assigns the MoveTo parameter values to global variables so they can be used by other javascript functions. Finally it executes a view show view Chime script command:

document.myoglobin.executeScript("view show view")

If you wish to use the MoveTo function in your own pages, you must modify this command with the name of the Chime image you wish to target (myoglobin in this case).  Also, the Chime image embed tag must have a Message Callback command. This directs the output of the view show view command to another javascript function which will be used to obtain the current orientation of the molecule. My page uses this embed tag command:

messagecallback="echo"

The javascript file also defines the function echo which has two parameters:

function echo(myoglobin,message)

The first parameter is the name of the Chime image and the second (message) is the string variable that will contain the output message from the Chime image. The echo function has two nested If / Then statements.  The first determines that a MoveTo command has been initiated by the MoveTo function.  This is necessary as the echo function will be called anytime the Chime image generates a message.   The second identifies the message which contains the output of the view show view command. The split and parseFloat commands divide the message into numeric variables which define the current orientation of the image on the screen. The values of the split command are assigned to convenient variable names (cxr = current x rotation, e.g.).  Finally a third function, MoveToCalc, is called to do the final calculations.

At this point, the program has the rotations, translations, and zooms needed to generate the desired and current views starting from the default orientation. The MoveToCalc function executes a series of linear algebra matrix manipulations which generate the parameters needed to use Chime's move command to rotate the molecule from the current to the desired view. Dr. Wells derived the algorithm for this calculation.  The diagram below schematically illustrates the actions of the MoveTo feature:

If you want to use MoveTo on your own pages, I have also created a simple page with all the necessary scripts in a single page.  You will need to modify the scripts and Chime embed tag as described above.