Jump to content
  • Advertisement
Sign in to follow this  
laeuchli

Extracting Angles From Camera Matrix

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

Dear All, I currently have a planet that I navigate around with a small control I've written(thanks to those who helped me with the problem I was having with that ;-)). Anyway the problem I was having with the control was that the rotation values were relative, ie if you rotated around the x axis enough, rotating in the z axis who no longer appear to be rotating in the Z direction. However I fixed this by having a quaternion with my current orientation, and then multplying it by a fixed quat whenver someone clicked on the appropriate control. For example Quat View(...);//Original view case CLICKED_LEFT: Quat Left(1,0,0,-.1); View*=Left; case CLICKED_RIGHT: Quat Right(1,0,0,.1); View*=Right; etc. So all is well with the world, and the control works great. Unfortuantly I was given the requirement that the control only activate when clicked on, the rest of the time, different camera classes will be active. So my problem is I'd like to update the control based on the camera matrix currently being created by a different part of the application. I can easily extract the translations, but once I get to the rotations I have a problem. The site (http://www.j3d.org/matrix_faq/matrfaq_latest.html) lists exactly how I should extract the angles, but unfortunatly, I have the same problem in reverse as I had with the camera control, ie, these rotations are cumlulative. When there is no rotation around the XY axises, I can easily extract the correct Z for use in my control, but once I start rotation in XY, Z is no longer correct. I suppose there is some way either by using the inverse of the rotations to produce what I want, or by looking at the two most recent copies of the rotation matrix to produce the increment the various angles have rotated, but I'm at a loss as how exactly to do this. If anyone could provide me with some advice I'd greatly apprciate it. Regards, Jesse

Share this post


Link to post
Share on other sites
Advertisement
Google for "euler to matrix", "quaternion to matrix", "euler to quaterion" depending on the type of conversion you need. You say angles so I guess "euler to matrix" or "matrix to euler" is what you want. Maybe tag "conversion" on the end.

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!