Rotations from matrix?

Hi , everyone .

I moved from Direct3d (Retained mode ) to OpenGL about a year ago and im rewriting a litte project ive been working on .
Its a sort of flight sim and I need the current rotations for an ADI ball .
ADI is an Attitude Direction Indicator .

It worked fine in DirectX cause I used the GetRotation to get the Up and Direction vector and used this formula to get my rotations :

xrot=atan2(dir.y,dir.z)*180/3.14; Pitch
yrot=atan2(dir.x,dir.z)*180/3.14; Yaw
zrot=atan2(up.x,up.y)*180/3.14; Roll

Now I use matrices for rotations but how to extract the rotations from that ?
Well , thats what Im asking for .

Hi,
Take a look at http://skal.planet-d.net/demo/matrixfaq.htm

Graphics Gems (vol 2 or 3, I forget) has code to break a 4x4 homogeneous matrix into its translation, rotation, scaling and shear components, if it’s not singular.

I stole this from elsewhere on the forums:

Use a matrix decompose routine, of course: http://www.acm.org/tog/GraphicsGems/gemsii/unmatrix.c
You may want to get to know the Graphics Gems site: http://www.acm.org/tog/GraphicsGems/

-Blake

Hi there,

Following on from Michail’s post, I was trawling the internet the other day (working out what gimbal lock was) and came across this web page. It’s a more recent version of the The Matrix and Quaternions FAQ.
http://www.cs.ualberta.ca/~andreas/math/matrfaq_latest.html

  • 5AmpFuse

Thanx guys.

That helped me