Don Hatch (hatch++at++hell.asd.sgi.com)
Tue, 11 Mar 1997 17:04:47 -0800
If I am understanding correctly, you want to compose (i.e. multiply)
the above quaternions together to accumulate the keyframes.
The following code seems to give a believable answer--
note that the final orientation (i.e. the composite
of the three 90-degree rotations) is equivalent to a single
90-degree rotation about the Y axis.
I assume you mean the rotations to be expressed in terms of the world
space axes (as opposed to the object space axes)--
if not, just multiply by the incremental rotation quaternion
on the left instead of the right.
(My impression is that you are willing to use the Performer math libs as
a calculator, but if you *really* want to do the quaternion multiplication
by hand, see the references at the end of the pfQuat man page.)
#include <Performer/pr/pfLinMath.h>
main(int argc, char **argv)
{
pfQuat qident, qx, qy, qz;
qident.makeRot(0, 1,0,0);
qx.makeRot(90, 1,0,0);
qy.makeRot(90, 0,1,0);
qz.makeRot(90, 0,0,1);
pfQuat keyframes[4];
keyframes[0] = qident;
keyframes[1] = keyframes[0] * qx;
keyframes[2] = keyframes[1] * qy;
keyframes[3] = keyframes[2] * qz;
pfQuat q;
for (k = 0; k < 3; ++k)
{
int i, n = 4; // number of steps from one keyframe to the next
for (i = 0; i <= n; ++i)
{
float t = (float)i/(float)n;
q.slerp(t, keyframes[k], keyframes[k+1]);
float angle, x, y, z;
q.getRot(&angle, &x, &y, &z);
printf("%f %f %f %f\n", angle, x, y, z);
}
printf("\n");
}
}
The output is:
0.000000 0.000000 0.000000 1.000000
22.500017 1.000000 0.000000 0.000000
44.999989 1.000000 0.000000 0.000000
67.500008 1.000000 0.000000 0.000000
89.999992 1.000000 0.000000 0.000000
89.999992 1.000000 0.000000 0.000000
92.181213 0.962637 0.191480 -0.191480
98.421036 0.862856 0.357407 -0.357407
107.978378 0.726831 0.485653 -0.485653
120.000000 0.577350 0.577350 -0.577350
120.000000 0.577350 0.577350 -0.577350
107.978378 0.485653 0.726831 -0.485653
98.421051 0.357407 0.862856 -0.357407
92.181213 0.191480 0.962637 -0.191480
89.999992 0.000000 1.000000 0.000000
Don
--
Don Hatch hatch++at++sgi.com (415) 933-5150 Silicon Graphics, Inc.
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:53 PDT