I have been tying to work backwards from a mesh's Transform matrix to work out what the mesh's rotation is in radians. Not having much luck.
Here is a bit of code i was trying but it only worked for some angles and i not smart enough to workout what to do next
playermesh = engine->FindMeshObject ( "turret.001" , 0 );
movable = playermesh->GetMovable ();
// Get mesh Position
start = movable->GetTransform().GetOrigin ();
// get mesh Rotation
pot = movable->GetTransform();
rotX = getM3xAngle(pot);
rotY = getM3YAngle(pot);
float AppSol::getM3xAngle ( csMatrix3 m3 )
//Rotation along the X-axis is represented by:
/// 1 0 0 \
//| 0 cos(a) -sin(a) |
//\ 0 sin(a) cos(a) /
return acos( m3.m22 );
float AppSol::getM3yAngle ( csMatrix3 m3 )
//Rotation along the Y-axis is represented by:
/// cos(a) 0 -sin(a) \
//| 0 1 0 |
//\ sin(a) 0 cos(a) /
return acos( m3.m11 );
obviously, this does not work but my trig not that good and I cannot work out how to do this.
any help welcome.
The easiest (but not most optimal) way to do this in cs would be the following code:
csVector3 euler_angles = q.GetEulerAngles ();
Not sure how to do it more optimally then this though.