VMD-L Mailing List
From: Alexei Podtelezhnikov (apodtele_at_kgi.edu)
Date: Thu Aug 04 2005 - 10:09:38 CDT
- Next message: Mgr. Lubos Vrbka: "wrapping and extra points in gromacs trajectories"
- Previous message: John Stone: "Re: PDB to STL help needed"
- Next in thread: John Stone: "Re: dihedral angles cleaned up"
- Reply: John Stone: "Re: dihedral angles cleaned up"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hi vmd-l!
May I suggest the following optimization to dihedral angle calculations that relies on atan2f, rather than signed_angle. It's just faster and cleaner.
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.2958f * atan2f(psin, pcos);
}
and we're done. I would drop signed_angle if nothing else uses it.
Thanks for vmd,
Alexei Podtelezhnikov, Ph.D.
- Next message: Mgr. Lubos Vrbka: "wrapping and extra points in gromacs trajectories"
- Previous message: John Stone: "Re: PDB to STL help needed"
- Next in thread: John Stone: "Re: dihedral angles cleaned up"
- Reply: John Stone: "Re: dihedral angles cleaned up"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]