#### Archived

This topic is now archived and is closed to further replies.

# Quick rotation question

This topic is 5475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

what does the matrix look like for the functions glRotatef() and glTranslatef()?

##### Share on other sites
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]

##### Share on other sites
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?

##### Share on other sites
You call glPopMatrix() to restore the GL_MODELVIEW matrix back to the state it was in before you called glPushMatrix();

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites
is it possible to do it the other way? i mean to transform the quad''s coordinates into the light''s space?

##### Share on other sites
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

1. 1
Rutin
22
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633308
• Total Posts
3011293
• ### Who's Online (See full list)

There are no registered users currently online

×