


zAngleOfRotation calculates the angle of rotation from a rotation matrix R A good online reference is: http://www.mathworks.com/access/helpdesk/help/toolbox/physmod/mech/mech_review7.html


0001 % zAngleOfRotation calculates the angle of rotation from a rotation matrix R 0002 % A good online reference is: 0003 % http://www.mathworks.com/access/helpdesk/help/toolbox/physmod/mech/mech_review7.html 0004 0005 function [alpha] = zAngleOfRotation(R) 0006 0007 alpha = 2*acos(min(1,sqrt(trace(R)+1)/2)); 0008 0009 % occasionally trace(R) is slightly greater than 3, making alpha complex 0010 %[trace(R)-3] 0011 %[ sqrt(trace(R)+1)/2 alpha]