From: Bennion, Brian (Bennion1_at_llnl.gov)
Date: Thu Oct 09 2014 - 15:09:58 CDT

Is there something wrong with just using the

measure dihedral {{atom1 moldid} { atom2 molid} {atom3 molid} {atom4 molid}}

command?
then if you have to you can convert the angles to a 0---360 format if needed instead of the -180 -->180 format.

Brian
 

________________________________________
From: owner-vmd-l_at_ks.uiuc.edu [owner-vmd-l_at_ks.uiuc.edu] on behalf of Aiswarya [aiswarya.pawar_at_gmail.com]
Sent: Thursday, October 09, 2014 11:32 AM
To: John Vmd; Vmd
Subject: vmd-l: Error while calculating rotational angle

Dear Users,
Am trying to calculate rotational angle for a given 4 atoms, am getting the value of angle correct but its not differentiating between +ve and -ve. Ie if the angle between 4 atoms is -177 degrees am getting 177 degree, and there is no -ve sign to it. Below is the script i have used.

> # Computes the dihedral angle of a bond
>
> set coord1 [lindex [[atomselect top "index 86" ] get {x y z}] 0]
> set coord2 [lindex [[atomselect top "index 89" ] get {x y z}] 0]
> set coord3 [lindex [[atomselect top "index 75" ] get {x y z}] 0]
> set coord4 [lindex [[atomselect top "index 23"] get {x y z}] 0]
> set v1 [vecsub $coord1 $coord2]
> set v2 [vecsub $coord3 $coord2]
> set v3 [vecsub $coord4 $coord3]
>
> set cross1 [vecnorm [veccross $v2 $v1]]
> set cross2 [vecnorm [veccross $v2 $v3]]
> set cos [vecdot $cross1 $cross2]
> set rotvec [veccross $cross1 $cross2]
> set sin [veclength $rotvec]
> set angle [expr atan2($sin,$cos)*(180.0/3.14)]
> return $angle

Please someone tell me were am going wrong.

Thank you so much,
Aiswarya