I want to get the local roll pitch yaw of my camera given it's angle axis rotation. The engine (Torque3D) I am using has a function called AngleAxisToPitchYaw and it gets the Pitch and yaw correctly, but doesn't give me any Roll. The code for it is:
AngAxisF aa;
dSscanf(argv[1], "%g %g %g %g", &aa.axis.x, &aa.axis.y, &aa.axis.z, &aa.angle);
//convert to radians
aa.angle = mDegToRad(aa.angle);
I want to get the roll as well though. I also have a conversion function to Euler, but I am not sure Euler is the same as Roll, Pitch, and Yaw. Also it seems to return a value when the camera doesn't appear to be rotated around the forward axis.
I finally figured it out. Just a little background in case someone who isn't using torque and wants a similar function. TransformF simply contains a Point3F position and a Angle axis rotation. A Point3F is simply 3 float values.
///brief Converts the transform's rotation to Roll, Pitch, Yaw.
///param trans Transform to be converted.
///return Roll, Pitch, and Yaw as a Point3F.
Point3F TransformToRollPitchYaw(TransformF trans)
{
// Get current object transform matrix
MatrixF objTx = trans.getMatrix();
// Get rotations from transform matrix
Point3F vec;
objTx.getColumn(1,&vec);
// Get X-vector for roll calculation
Point3F xv;
objTx.getColumn(0,&xv);
// Calculate PRH (x = pitch, y = roll, z = heading)
Point3F rot(-mAtan2(vec.z, mSqrt(vec.x*vec.x + vec.y*vec.y)), mDot(xv,Point3F(0,0,1)), -mAtan2(-vec.x,vec.y) );
// Set up vars
F32 pitch = mRadToDeg(rot.x); // Pitch
F32 yaw = mRadToDeg(rot.z); // Heading
F32 roll = mRadToDeg(rot.y); // Roll