MATLAB: Compute Rotation Angle from Procrustes Rotation Matrix

#procrustes #svd #rotation

Hi!
I'm experimenting with procrustes matlab funcion for image alignment. My problem is that I need to compute the actual rotation angle and not just the transform. Could someonde give me some tip in computing the angle from the rotation matrix.
Thanks!

Best Answer

To do that you need to receive the third output from 'procrustes' which is a structure. Its 'T' component gives the rotational component of the transformation from the input Y to the output Z:
Z = b*Y*T + c;
Assuming it is not a reflection, the matrix T should be of the form
T = [cos(a),sin(a);-sin(a),cos(a)]
where a is the rotation angle from Y to the rotated Y*T. Therefore you can find the angle with
a = atan2(T(1,2),T(1,1));
which gives an angle in the range -pi < a <= pi. (A reflection would have T(1,1) and T(2,2) of opposite sign.)
Related Question