guille

11-09-2001, 12:28 AM

I wanted to build myself the matrix that glRotate creates. In the redbook it is written:

The call glRotate*(a, x, y, z) generates R as follows:

Let v = (x, y, z)T, and u = v/| |v| | = (x', y', z')T.

Also let

http://ask.ii.uib.no/library/SGI_bookshelves/SGI_Developer/books/OpenGL_PG/figures/eqapg03.gif

Then

http://ask.ii.uib.no/library/SGI_bookshelves/SGI_Developer/books/OpenGL_PG/figures/eqapg04.gif

But I am doing something wrong because my matrix is different from the one that glRotate creates.

I am creating it like this:

Vnorm(vect_rot); // u

double uu = vect_rot[0]*vect_rot[0]+vect_rot[1]*vect_rot[1]+vect_rot[2]*vect_rot[2];

double i_uu = 1 - uu;

double cos_tetha = cos(tetha), sin_tetha=sin(tetha);

double M[4][4]= { uu+i_uu*cos_tetha, -vect_rot[2]*sin_tetha, vect_rot[1]*sin_tetha, 0,

vect_rot[2]*sin_tetha, uu+i_uu*cos_tetha, -vect_rot[0]*sin_tetha, 0,

-vect_rot[1]*sin_tetha, vect_rot[0]*sin_tetha, uu+i_uu*cos_tetha, 0,

0, 0, 0, 1};

Is this correct??

Thank YOU!

=]

The call glRotate*(a, x, y, z) generates R as follows:

Let v = (x, y, z)T, and u = v/| |v| | = (x', y', z')T.

Also let

http://ask.ii.uib.no/library/SGI_bookshelves/SGI_Developer/books/OpenGL_PG/figures/eqapg03.gif

Then

http://ask.ii.uib.no/library/SGI_bookshelves/SGI_Developer/books/OpenGL_PG/figures/eqapg04.gif

But I am doing something wrong because my matrix is different from the one that glRotate creates.

I am creating it like this:

Vnorm(vect_rot); // u

double uu = vect_rot[0]*vect_rot[0]+vect_rot[1]*vect_rot[1]+vect_rot[2]*vect_rot[2];

double i_uu = 1 - uu;

double cos_tetha = cos(tetha), sin_tetha=sin(tetha);

double M[4][4]= { uu+i_uu*cos_tetha, -vect_rot[2]*sin_tetha, vect_rot[1]*sin_tetha, 0,

vect_rot[2]*sin_tetha, uu+i_uu*cos_tetha, -vect_rot[0]*sin_tetha, 0,

-vect_rot[1]*sin_tetha, vect_rot[0]*sin_tetha, uu+i_uu*cos_tetha, 0,

0, 0, 0, 1};

Is this correct??

Thank YOU!

=]