   Computing roll. pitch yaw
  I am having trouble converting D3DXMATRIX. which has the Position and orientation details of an object in directx to Roll, pitch, yaw.I am using the following code//First converting to quaternionD3DXQUATERNION qt  ;D3DXQuaternionRotationMatrix(&qt, &d3dMat);//Then extracting roll pitch yawfloat q1 = qt.w;float q2 = qt.x;float q3 = qt.y;float q4 = qt.z;float phi =   atan2( (q1*q3 + q2*q4) ,  q2*q3 - q1*q4)    ; float theta = acos( -q1*q1 - q2*q2 + q3*q3 + q4*q4);float gamma = -atan2( (q1*q3 - q2*q4) ,  q2*q3 + q1*q4)    ; Please help me correct it..   
  You should be able to get an answer here:Conversion_between_quaternions_and_Euler_angles;  I highly recommend using the Configurable Math Library (CML) to do this job for you. It allows you to convert it to any Euler order. XYZ, XZY, XYX, etc.. It also allows you to convert those back to a matrix with extreme reliability. We incorporated CML into our project exclusively for this functionality.   