In my current project I need to find the angular distance of direction vector from a 3D rotation matrix.
The legacy code which suppose to do that is buggy and is not working. Even it is buggy I want to share it because it may help understanding my problem.
double angularDiff( bool isSideAngle, const Matrix& in3DRotationMatrix, const Vector& in3DDirection )
{
// Unit vector convertion
in3DDirection.Normalize();
// Simple matrix vector multiplication
Vector newDir = in3DRotationMatrix*in3DDirection;
// Code suppose to find side angle difference
// or forward angle difference according to boolean parameter
if ( isSideAngle )
result = atan2(newDir[1], newDir[0]);
else
result = atan2(newDir[2], newDir[0]);
return result;
}
Is what is missing in the method above something simple or should I change my approach totally? Given a direction vector what is the best method to find angular distance in X and Y directions from a rotation matrix?
in3DDirectionin world coordinates or in local coordinates? - John Alexiou