function [v,theta] = rot_matrix_to_axis_angle(R) theta = acos( 0.5*(trace(R)-1)); if abs(theta) < 1e-7 v = [0;0;1]; else v = (1/(2*sin(theta))) * [ R(3,2)-R(2,3); R(1,3)-R(3,1); R(2,1)-R(1,2)]; end