From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Thu Jul 07 2011 - 16:59:46 CDT

On Thu, Jul 7, 2011 at 10:22 AM, Mark Cunningham <cunningham_at_utpa.edu> wrote:
> Sara:
>
> In trying to convert from radians to degrees, 180/3.14159 is only correct to
> 5 decimal places, where double precision arithmetic has approximately 12
> decimal places of precision.  This may seem unimportant but can lead to
> hard-to-trace bugs in more complex calculations.  Better practice is to use
> the value of pi to machine precision, which can be obtained from calling the
> arc cosine function with the argument -1.  Also, tcl is an interpreted

actually VMD provides a Pi at machine precision. just add:

global M_PI

and then you can use $M_PI throughout.

> language,
> meaning that every time you go through the loop tcl has to parse the string
> 180/3.14159 and decide what to do with it.  Compiled languages like Fortran

actually, tcl does byte-compile this, so the parsing is only done once.
but the execution of the preparsed loop body is still very slow compared
to C++ or Fortran.

cheers,
     axel.

-- 
Dr. Axel Kohlmeyer
akohlmey_at_gmail.com  http://goo.gl/1wk0
Institute for Computational Molecular Science
Temple University, Philadelphia PA, USA.