# Extracting Angles From Camera Matrix

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

## 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 on other sites
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 on other sites
Yes I'm already extracting the euler angles from the matrix, but they arent exactly what I need.

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 11
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013156
×