Extracting Angles From Camera Matrix

Started by
1 comment, last by laeuchli 16 years, 9 months ago
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
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.
Yes I'm already extracting the euler angles from the matrix, but they arent exactly what I need.

This topic is closed to new replies.

Advertisement