|WikiProject Mathematics||(Rated Start-class, Low-importance)|
|WikiProject Molecular and Cellular Biology||(Rated Start-class, Low-importance)|
The red arrows in the figures on this page are misleading. As vectors, the arrows should be on the opposite end. -- JackSnoeyink 04:00, 18 April 2007 (UTC)
Problems with first algorithm
As well as being longer and more complex than the method given below it the algorithm can fail with a divide by zero error, if the 'arbitrary vector' is such that either Va or Vb is zero. The way to avoid that is put the whole thing in a while loop until the product of their magnitudes is non-zero, but that would make it even less clear. And even if not exactly zero it can be very inaccurate for vectors close to zero, due rounding errors. I.e. it's a generally poor algorithm.
- This seems to be the sort of thing that would be better explained in plain words (preferably with a picture) than with code. At any rate, it is distilled in the observation that in order to find a normal vector, one can take a basis of tangent vectors to the plane, and apply Gram-Schmidt to any extension of this basis to a basis of the Euclidean space. The relevant implementation details would be in the Gram-Schmidt algorithm itself, and the selection of the vector that completes the bases. This has the advantage over the cross product approach because it works in any dimension. The pseudocode itself is so problematic that it should be removed immediately. I was going to comment more about this, but I think the issues are sufficiently obvious and numerous that they will not escape detection. Sławomir Biały (talk) 12:19, 7 March 2010 (UTC)
Problem with the Figure 4: The backbone dihedral angles of proteins.
atan2 formula does not give the correct sign in some cases
does not give correct results because the first argument is always positive. Using this formula, is always positive. I believe that the correct formula is
As a citation, I propose formulae (3) and (4) in Blondel and Karplus, 1995 (DOI: 10.1002/(SICI)1096-987X(19960715)17:9<1132::AID-JCC5>3.0.CO;2-T). The above formula is a slight manipulation of the sin and cos formulae cited. — Preceding unsigned comment added by John Jumper (talk • contribs) 03:52, 1 November 2013 (UTC)
- I'm not sure. A dihedral angle, defined as the angle between two planes should be between 0 and 180 degrees, so atan2(abs(y),x) should work fine. I don't know under what conditions you want the answer as >180. Perhaps the intro should say the angle is between 0 and 180? Tom Ruen (talk) 06:56, 2 November 2013 (UTC)
- If you define the dihedral angle between two planes as the angle you need to rotate the first plane so the normals are parallel and unidirectional, then the angle might be more than 180 (or, more elegantly, between -180 and 180). This is exactly the definition used in biochemistry to report covalent bond torsion angles. --RasF (talk) 12:02, 8 November 2013 (UTC)
- I apologize for the late reply. As used in biochemistry, dihedral angle really refers to the angle between the vectors r2->r1 and r3->r4, after both vectors have been projected onto the plane whose normal is given by the vector r2->r3. Since this angle is in the plane, it is defined on [-180,180]. As an example of the use of this definition, see Ramachandran plot, noting that both axes on the figures are on [-180,180]. From a more mathematical perspective, the dihedral angle defined on (-180,180) is a continuous function of the 4 points, so long as 3 consecutive points are not collinear. Reversing the order of the points negates the dihedral angle. At the very least, I would note the difference in convention (I started this edit because I copied this formula into a piece of code where I expected the biochemistry definition and wasted an hour tracking down the bug). That the biochemist follow the signed dihedral convention is documented by the Blondel and Karplus paper from 1995. John Jumper (talk) 08:56, 20 November 2013 (UTC)
- I also just implemented a small script with a Computational Chemistry background for which I needed the dihedral angle. And I can confirm that the current atan2()-formula did not work the way I needed. The replacement suggested here worked fine. (Tobias) 10:05, 25 November 2013 (UTC) — Preceding unsigned comment added by 184.108.40.206 (talk)