Quick rotation question

Started by
6 comments, last by adam17 20 years, 5 months ago
what does the matrix look like for the functions glRotatef() and glTranslatef()?
Advertisement
The matrix for glTranslatef(x,y,z) looks like this:
1 , 0 , 0 , 00 , 1 , 0 , 00 , 0 , 1 , 0x , y , z , 1

The matrix for glRotatef(theta,x,y,z) is much more complex:
float c = cosf(theta);float s = sinf(theta);x*x(1-c)+c   , y*x(1-c)+z*s , x*z(1-c)-y*s, 0x*y(1-c)-z*s , y*y(1-c)+c   , y*z(1-c)+x*s, 0x*z(1-c)+y*s , y*z(1-c)-x*s , z*z(1-c)+c  , 0     0       ,       0      ,      0      , 1

And there you have it.

[edited by - GreenToad on November 17, 2003 1:01:34 AM]
here is what im trying to acheive. i want to take a quad (its a test object) and rotate on it''s y axis at some arbitrary point. so far i am using just glPushMatrix(), glTranslatef(), and glRotatef(). next i want to do a dot product on the vertices of the quad between the light and the face normal. my problem is im not entirely sure about how to put the vertex coordinates into the space before i performed the glPushMatrix (i think its called object space). how do i transform the values back?
You call glPopMatrix() to restore the GL_MODELVIEW matrix back to the state it was in before you called glPushMatrix();
i know how to do that. what im not clear on is how to take the quad''s vertex coordinates and dot product them with the light''s coordinates. they are in two different matrices. the quad is in between the glPushMatrix() and glPopMatrix(). the light is outside of the quad''s matrix.
You need to transform light into quad''s object space before doing dot3. You can do this multiplying light position by inverse of object transformation matrix.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
is it possible to do it the other way? i mean to transform the quad''s coordinates into the light''s space?
you could, but its inefficient. A quad has four coordinates, a light one. In this case the difference is trivial, but for anything more complex it becomes much easier just to translate the light

This topic is closed to new replies.

Advertisement