Jump to content
  • Advertisement
Sign in to follow this  
marcus12

glRotatef() transformation

This topic is 2539 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

Hi,
AS shown in figure if

int x1= 100.0, y1= 100.0, x2= 100, y2= 200.0


glTranslatef(100.0, 100.0, 0.0)
glRotatef(30.0f,0.0, 0.0, 1.0)

glBegin(GL_LINES)
glVertex2f(x1, y1);
glVertex2f(x2 , y2);
glEnd();


Then as we can see the RED LINE is the actual line and according to the co-ordinate system ie BLACK LINES the position of the point 'A' in figure is (100,100)

But when it is translated then the co-ordinate is shifted to (100,100) as shown by GREEN LINES and then rotated so what will be the position of point 'A' , How to calculate it????

All suggestions are welcome

Share this post


Link to post
Share on other sites
Advertisement
No idea what you are asking. You took a point 100,100
Then rotated it 30 degrees to make it something like 75,125
Then translated it by 100,100
= 175, 225

Share this post


Link to post
Share on other sites

No idea what you are asking. You took a point 100,100
Then rotated it 30 degrees to make it something like 75,125
Then translated it by 100,100
= 175, 225



I just want to know how to find the position of a point before and after rotation.

Share this post


Link to post
Share on other sites
The function definitions have the transformation matrices.

http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml
http://www.opengl.org/sdk/docs/man/xhtml/glTranslate.xml

Share this post


Link to post
Share on other sites
glGetDoublev(GL_MODELVIEW_MATRIX) look up glGetDouble, call that function after your glRotate/translate functions, they will give you a 4x4 matrix. Multiply your point x,y,z by the 4x4 matrix.You have to perform the math your graphics card does.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!