Re: veccross implementation in tclforces

From: Victor Kwan (
Date: Wed Sep 11 2019 - 17:59:58 CDT

Since veccross isn't implemented in C in VMD, you can just put this in the beginning of your tclforces script (taken from vmd's source code)

proc veccross {x y} {
    foreach {x1 x2 x3} $x { break }
    foreach {y1 y2 y3} $y { break }
    set ret {}
    lappend ret [expr { $x2 * $y3 - $y2 * $x3}]
    lappend ret [expr { - $x1 * $y3 + $y1 * $x3}]
    lappend ret [expr { $x1 * $y2 - $y1 * $x2}]
    return $ret

On Wed, Sep 11, 2019 at 5:56 PM Daniel Strahs <<>> wrote:
Hello all:

I'm implementing a tclforces script to rotate part of a protein around a calculated axis of rotation.

The script, based on the rot-a.tcl script from the forces tutorial, calculates the axis of rotation (R) at each step, and then solves for the vector (A) from the atom to the rotation axis that is perpendicular to the rotation axis. The direction of rotation is then the cross product of R x A.

In implementing this script, I used veccross to determine the RxA vector product. Unfortunately, the simulation fails immediately with the error FATAL ERROR: wrong # args while executing "veccross $comvector $atom2rotvec". In this example, comvector is R and atom2rotvec is A. Both comvector and atom2rotvec are vectors.

I edited the script slightly to test it with VMD (getting coords and masses using atomselect), and the script works fine. It computed a rotational force for each atom that produced the correct rotation, and veccross has no problems with it's input.

Is veccross implemented in tclforces? I could always compute the cross product with brute force explicit sums, but I did like the elegance of veccross.

Thanks for any pointers!

Daniel Strahs
Biology Dept
Pace University

This archive was generated by hypermail 2.1.6 : Tue Dec 31 2019 - 23:20:56 CST