Dihedral angles - how to calculate
Martyn Winn
m.d.winn at dl.ac.uk
Fri Feb 21 04:41:13 EST 1997
Andrew Dalke wrote:
>
> // angle between them
> return(geomValue = angle(n1, n2));
> }
>
> and the funtions used here are defined as:
>
> extern float angle(float *a, float *b) {
> register float amag = sqrtf(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
> register float bmag = sqrtf(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]);
> register float dotprot = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
> if (amag == 0 || bmag == 0) {
> return 180;
> }
> return (57.2958 * acosf(dotprot / (amag * bmag)));
> }
>
> Andrew
> dalke at ks.uiuc.edu
Here you calculate cos(angle), and when you do the acos there will be an
ambiguity in the sign of the angle, no? And I think this is what the
original
poster was worried about.
The way we do it, is to calculate (in your notation):
(n1 x n2) . r2 = |n1| |n2| |r2| sin(angle)
(n1 . n2) * |r2| = |n1| |n2| |r2| cos(angle)
and then use the Fortram atan2 function which takes the atan of the
ratio. Having
both arguments removes the sign ambiguity.
Think that's right....
Martyn
More information about the Xtal-log
mailing list