Any help creating a quaternion methods section for the article would be greatly appreciated. Also, I wonder if the final equation shown is sufficient for this article, or whether I should expand the final answer to show the full calculation of rxx, rxy and the final values of rotated vector in terms of V1 and V2. David E. Volk 17:46, 8 March 2009 (UTC)
Paper on internet
I found a copy of the Möller-Hughes paper here. It seems that the present CZ article lacks the general formula and only gives the formula for the special case of almost parallel V1 and V2 (plus typo).
Question: what is the use of the rotation matrix? Usually such a matrix is used to construct V2 from V1, but now V2 is already known.
--Paul Wormer 00:30, 8 April 2009 (UTC)
Here's how I used it
V1 and V2 can be any direction with the equation given, not nearly parallel. I also have the paper and have been using it for vectors that are often nearly perpendicular. There are tons of ways to use these rotations in computer programs. Personally, I used it a few weeks ago to write a program that creates DNA atomic structures from secondary structure information. After an unusual bulge or kink in the DNA, say a 5-base bulge on one side, the program translates the entire structure so the last base pair's center is at (0,0,0) and then rotates the entire structure such that the last base pair's helical axis points in the direction (0,0,1), after which additional DNA base pairs to can be simply stacked right up on top. David E. Volk 12:55, 8 April 2009 (UTC)
- It seems to me that the M-H formula for non-parallel V1 and V2 is easier to use (it does not need the decisions about relative sizes of elements). As you say there are tons of rotation formulas and the one you gave is probably one of the least known. The eq. on the top of the page 2 of the M-H paper is very well-known and goes back to Euler, maybe we should rather give that one? (Considering CZ is a general encyclopedia)--Paul Wormer 14:05, 8 April 2009 (UTC)
- Before I used this method, I perused alot of literature and computer programming sites looking for various pros and cons of different methods, and the M-H method seemed to be quite popular with computer programmers, mostly for the speed of calculation (no square roots or inverse trig), but also to avoid so-called "gimbel lock" when vectors are nearly parallel to an axis, causing trig functions to approach infinity. Others were huge supporters or huge detractors of the Quaternion method. Perhaps we should do a science citation search on the M-H method and see what later literature, rather than computer programmers, think of the method. David E. Volk 15:44, 8 April 2009 (UTC)
- There are two considerations. First there is an enormous precomputer literature about rotations starting with Euler around 1760. I definitely feel that some of that should be covered (it so happens that I know quite a bit about it and I can do it). The second issue is efficiency of the equations for computer programming. Moller and Hughes (M-H) make a point of this and give timings of their code. I looked at their code and it uses the general formula for non-parallel vectors and only if the vectors are nearly parallel they use the equation given by you in the article. This leads me to suspect that their general formula is faster. --Paul Wormer 16:15, 8 April 2009 (UTC)
- In the time taken to determine if the two vectors are nearly parallel, one can simply calculate which axis to use for equation (2) of the M-H paper. Does the code you looked at use equation (1) on page 2, which is a simplified version of Foley's method? It seems to me (no expert!) that equation (1) is very fast, but not guaranteed to work for all vectors, while (2) is also very fast but essentially "never" fails. I do agree that a historic perspective starting from Euler, and the associated pitfalls, should be included before approval of this article, which is naturally a long way off yet. David E. Volk 17:45, 8 April 2009 (UTC)
- Yes, the code begins by checking if V1.V2 is close to 1. If it is not, Eq. 1 is used. If the inner product is almost 1 then Eq. 2 (listed by you) is used. BTW "Foley's method" gives much too much credit to Foley. As I wrote before, the "Foley equation" goes probably back to Euler and is in any book that treats the rotation group.--Paul Wormer 18:33, 8 April 2009 (UTC)
I'm puzzled by this paper of M-H. They state that their formula is unstable when t·f = cos(t,f) is close to unity [t and f are unit vectors] because their matrix elements contain
Later they thank somebody for pointing out the high-school algebra fact that
But this means that their formula is stable for all angles (t,f), which doesn't surprise me since their equation seems to me a fairly trivial rewrite of the "Foley equation" which is stable. I'll ask our numerical analyst Jitse Niesen for advice--Paul Wormer 01:01, 9 April 2009 (UTC)
- It will cost me some time to give a definite answer. It's possibly best to look in the literature. But my intuition is that your remark is plausible. Using the "high-school algebra fact" in Equation (1) in the M-H paper quite possibly eliminates the instability when f and t are approximately equal. I think there is another instability present when f ≈ −t, but that's probably less relevant. It looks like (1) is faster than (2). Besides, (2) probably has another problem: the vector v = p − t might be very small, so the denominator v · v becomes close to zero (this cannot happen though when f and t are approximately equal). -- Jitse Niesen 04:17, 9 April 2009 (UTC)
- Thank you Jitse. In the meantime I, too, gave it some thoughts:
- When f ≈ t then the modified Eq. (1) gives a rotation matrix close to the identity matrix, which is to be expected and not very useful.
- When f ≈ − t then the modified Eq. (1) breaks down, which is basically due to the fact that the two vectors are connected by minus the identity matrix, which is not a rotation matrix. If we want to rotate f to t one must choose a rotation axis. When f = − t there are infinitely many rotation axes to choose from: the problem is undetermined.
- I think M and H are cheating when they introduce p, there are no "God given" coordinate axes in a problem like this. You may argue that you do have a fixed laboratory system of coordinate axes (a lab frame), for instance defined by a laser beam, a magnetic field or something like it. But then the choice of orienting your molecule in the lab frame is arbitrary, one day you will orient it this way, the next day another way. This means that the algorithm depending on the choice of p will give different rotation matrices from one day to the next.
- If I were to solve the problem, I would use Eq. (1) while avoiding "from" (f) and "to" (t) pairs that are on one line. (Being on one line is coordinate independent, i.e., it is true whatever orientation you choose for your molecule).
- Eq. (1) is very easy to derive, no "considerable algebra" is necessary, see User_talk:Paul_Wormer/scratchbook.
- --Paul Wormer 15:56, 9 April 2009 (UTC)