Jump to content
  • Advertisement

Archived

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

adam17

Quick rotation question

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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
is it possible to do it the other way? i mean to transform the quad''s coordinates into the light''s space?

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!