VMD-L Mailing List
From: Alexei Podtelezhnikov (apodtele_at_kgi.edu)
Date: Thu Aug 04 2005 - 11:19:31 CDT
- Next message: Bob Johnson: "Video card driver"
- Previous message: John Stone: "Re: dihedral angles cleaned up"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hi vmd-l,
The following optimization to dihedral angle calculations in utilities.C, which relies on atan2f, rather than signed_angle, makes it a lot cleaner and faster.
float dihedral(const float *a1,const float *a2,const float *a3,const float *a4)
{
float r1[3], r2[3], r3[3], n1[3], n2[3];
vec_sub(r1, a2, a1);
vec_sub(r2, a3, a2);
vec_sub(r3, a4, a3);
cross_prod(n1, r1, r2);
cross_prod(n2, r2, r3);
float psin = dot_prod(n1, r3) * sqrtf(dot_prod(r2, r2));
float pcos = dot_prod(n1, n2);
return 57.2957795f * atan2f(psin, pcos);
}
and we're done. I would drop signed_angle altogether if nothing else uses it.
Thanks for vmd,
Alexei Podtelezhnikov
- Next message: Bob Johnson: "Video card driver"
- Previous message: John Stone: "Re: dihedral angles cleaned up"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]