Archived

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

adam17

Quick rotation question

Recommended Posts

The matrix for glTranslatef(x,y,z) looks like this:

1 , 0 , 0 , 0
0 , 1 , 0 , 0
0 , 0 , 1 , 0
x , 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, 0
x*y(1-c)-z*s , y*y(1-c)+c , y*z(1-c)+x*s, 0
x*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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites