Hill_Brian++at++amelnx.advmar.com
Wed, 13 Dec 95 18:16:50 EST
I was trying to convert pfmatrix notation to pfcoord notation
and I found something I don't understand. I tried to go from
euler to matrix, back to euler, and back to matrix notation
and the results I get aren't consistent. Can anyone explain
why this is happening?
I've included the code below.
I create a matrix to rotate 90 degrees about the x axis
using pfMakeEulerMat (mat, 0.0f, 90.0f, 0.0f). It creates the
following matrix:
1.000 0.000 0.000 0.000
0.000 0.000 1.000 0.000
0.000 -1.000 0.000 0.000
0.000 0.000 0.000 1.000
I call pfGetOrthoMatCoord (...) to translate it to pfcoord
notation and get the following:
x 0.000 y 0.000 z 0.000 h 0.000 p 90.000 r 90.000
^^^^^^
I expected to get:
x 0.000 y 0.000 z 0.000 h 0.000 p 90.000 r 0.000
^^^^^
When I call pfMakeCoordMat (...) using
x 0.000 y 0.000 z 0.000 h 0.000 p 90.000 r 90.000
I get the following matrix:
0.000 1.000 0.000 0.000
0.000 0.000 1.000 0.000
1.000 0.000 0.000 0.000
0.000 0.000 0.000 1.000
Again, I call pfGetOrthoMatCoord (...) to translate the
above matrix to pfcoord notation and get the following:
x 0.000 y 0.000 z 0.000 h 0.000 p 90.000 r 0.000
^^^^^
Why do they change back and forth like this?
Thanks,
Brian Hill
hill_brian++at++advmar.com
==============================================================================
#include <stdlib.h>
#include <stdio.h>
#include <Performer/pf.h>
#include <Performer/pr.h>
void main (void)
{
pfMatrix mat;
pfCoord crd;
int i;
/* matrix to rotate 90 degrees about x axis (pitch) */
pfMakeEulerMat (mat, 0.0f, 90.0f, 0.0f);
printf ("======= Euler Mat 90 deg x axis =======\n");
/* print the matrix elements */
for (i=0; i<4; i++)
printf ("\t%8.3f %8.3f %8.3f %8.3f\n",
mat[i][0],mat[i][1],mat[i][2],mat[i][3]);
/* get coord representation of matrix */
pfGetOrthoMatCoord (mat, &crd);
printf ("======= Coords of same matrix =======\n");
/* print the coord elements */
printf ("\tx %6.3f y %6.3f z %6.3f h %6.3f p %6.3f r %6.3f\n",
crd.xyz[0], crd.xyz[1], crd.xyz[2],
crd.hpr[0], crd.hpr[1], crd.hpr[2]);
/* get matrix representation of coord */
pfMakeCoordMat (mat, &crd);
printf ("======= Matrix from Coords =======\n");
/* print the matrix elements */
for (i=0; i<4; i++)
printf ("\t%8.3f %8.3f %8.3f %8.3f\n",
mat[i][0],mat[i][1],mat[i][2],mat[i][3]);
/* get coord representation of matrix */
pfGetOrthoMatCoord (mat, &crd);
printf ("======= Coords of same matrix =======\n");
/* print the coord elements */
printf ("\tx %6.3f y %6.3f z %6.3f h %6.3f p %6.3f r %6.3f\n",
crd.xyz[0], crd.xyz[1], crd.xyz[2],
crd.hpr[0], crd.hpr[1], crd.hpr[2]);
}
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:08 PDT