next up previous contents index
Next: Vectors Up: No Title Previous: sleep

Vectors and Matrices

   

Tcl does not handle mathematical expressions very well. It is slow at evaluating expressions, and provides no facility for handling vectors or matrices. Since the latter two are needed for structure analysis, we have added routines to manipulate them. The routines themselves are independent of VMD, but do require TclX for a couple functions, such as lassign. The routines are loaded during the evaluation of the $env(VMDDIR)/scripts/vmd/vmdinit.tcl script.

A vector in VMD is a list of numbers. All of the vector routines but one will work with vectors of any length; veccross will only use vectors of three numbers. A matrix is a 4x4 collection of numbers stored as a list of 4 vectors of 4 numbers, in row-major form.

Following are descriptions and examples of all the commands. For more examples of vectors, though without much documentation, the script used to test the vectors implementation is located at $env(VMDDIR)/scripts/vmd/test-vectors.tcl. See also the chapter on writing scripts for VMD.

Since Tcl is slow at math, some of these commands have been reimplemented in C++. (The original definition is in the vmd script distribution, but it is redefined later on inside VMD). At times, the speedup is a factor of 40 or more. These commands are noted by (C++).





Justin Gullingsrud
Tue Apr 6 09:22:39 CDT 1999