Jump to content
  • Advertisement


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


Getting rotated points from GL

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

I need to get the points from a rotation from the modelview matrix i have code like
  ::glTranslatef(1, 1, 0);
  ::glRotatef(180, 1, 0, 0);
  ::glTranslatef(0, 0, 0);
  float mm[16];
  ::glGetFloatv(GL_MODELVIEW_MATRIX, mm); 
Im rotating 180 about the X axis at (1, 1, 0). I think in rotations in 3D graphics if i can remember the matrices are cumulative so I think you must specify the operations in reverse. My modelview matrix is as follows: [ 1 0 0 (*x) 0 ] [ 0 -0.50000 -0.86625 (*y) 0 ] [ 0 0.86625 -5.00000 (*z) 0 ] [ 1 0.50000 9.13398 1 ] My understanding is that *x, *y, *z elements in the matrix should contain the new rotated x, y and z coordinates, but instead there all zeros. I know C stores matrices funny, but the bottom right element in this matrix should be a 1, so, it looks right there (ie. doing a transpose wont help). Can anyone help, All the best, Keith!

Share this post

Link to post
Share on other sites
To rotate a point by a matrix, you need to postmultiply it by the 3x3 rotation submatrix. Ie, if M is your rotation submatrix then v''=M*v

Google for the matrix and quaternion FAQ if you don''t know how to do that. Oh, and remember that OpenGL matrices are stored in column major format.

Share this post

Link to post
Share on other sites
I got it going after, i forgot to call


And yeah the elements 12, 13, 14 are the x,y, z coordinates due to GL storing matrices in Column Major format.

Thanks for the help,

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.

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!