The inverse of a quaternion.

Hello, all,

I am working on the QuakeIII md3 model loading code, everything works fine now except that the rotation interpolating part. This is done using crazy quaternions, and the problems is that the torso part rotates in the reverse direction of what it should do. I try to inverse the quaternion so that I can reverse the direction the torso rotates. Can anybody show me how to? Thanks.

http://skal.planet-d.net/demo/matrixfaq.htm

[This message has been edited by orbano (edited 01-24-2004).]

The inverse of a quaternion q.

Lets assume q is normalized, i.e. |q| = 1.

Usually, normalized quaternions are associated,
with rotations in R³. Rotations in R³ are
orthogonal matrices having determinant ±1.
The definition of an orthogonal matrix says
that the inverse equals its transpose.

So, one “solution” (for people having only a minor
knowledge of quaternions) is to convert the quat.
to a rotation in R³, transpose that rotation
and convert it back to a quaternion. This will give
you the inverse quaternion.

But this is not necessary, its far more easier.
If the quat. q is normalized, then the inverse
quat. q^(-1) of q is given by :

q^(-1) = q^t

q^t is the so-called conjugate (which can be
viewed as of transposing the equivalent rotation
matrix). Conjugation (in a complexified space) is
done by inverting the signs of the imaginary
numbers. For example, the conjugate of a complex
numbers z = a + ib is z^t = a - ib. And this is the
same with quaternions:

Let q = a + ib + jc + kd be a quaternion, then

q^t = a - ib - jc - kd

is the conjugate quaternion of q.

So the inverse is easily be found.

A side: Being the inverse of an element implies
that, if you combine the inverse of an element
with the element itself then you will get the
identity element.

For a normalized quat this means:

q * q^t must equal 1!

cu,
m i s s i l e