Subject: Quaternion formula needed

From: [email-masked] (Gabriel Berriz)
Date: Thu, 5 Jun 1997 12:14:36 -0400

Dear netters:

Is there a formula that will take as argument a set of two orthonormal
vectors X, Y in R^3, and yield a unit quaternion Q such that

                                  -1
                        Q*(0, X)*Q  = (0,1,0,0)

                                  -1
                        Q*(0, Y)*Q  = (0,0,1,0)

(It would then be automatically true that:
                                      -1
                        Q*(0, X x Y)*Q  = (0,0,0,1) .)

I wrote a simple two-stage algorithm to perform the required
computation, but it is rather inelegant, with several if-then
statements to handle "pathological" situations.  I'd prefer an
analytical expression, if it exists, that would allow general
mathematical manipulation.  Any information on this problem would be
greatly apreciated.

Thank you very much,

Gabriel Berriz
[email-masked]

---

From: Konrad Hinsen <[email-masked]>
Date: Thu, 5 Jun 1997 20:56:06 +0200

>                         Q*(0, X x Y)*Q  = (0,0,0,1) .)

That depends on what you call "a formula". I doubt there is a formula
in terms of sines, cosines, and basic arithmetic; you always run into
singularities when doing the conversion in this direction. But there
is no singularity in the final result, i.e. Q as a function of X and Y
is well-behaved. So if you are willing to use a "nonstandard"
function, which would nevertheless have nice and easy to determine
analytical properties, you can probably come up with an analytic form.
The special function could numerically be calculated just like any of
the standard ones (i.e. by polynomial approximation).

Entering "speculation mode", I'd attempt to construct the full
transformation as two steps (first X->(1,0,0), then Q*Y->(0, 1, 0)).
For the first one do X x (1,0,0) = axis*sin(phi), and multiply it by
sin(phi/2)/sin(phi), expressed as a function of cos(phi) which you get
>from the dot product. If I didn't overlook anything that function
should be singularity-free. The second step would be easier since the
rotation axis is known to be (1, 0, 0). Once you have the quaternions
for the two parts, just take the product. The resulting formula won't
be simple, of course...
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: [email-masked]
Laboratoire de Dynamique Moleculaire   | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-4.76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------