Home > FR3DSource > zAxisAngleRadians.m

zAxisAngleRadians

PURPOSE ^

zAxisAngleRadians computes the axis and angle of rotation in an

SYNOPSIS ^

function [axis, angle] = zAxisAngleRadians(R)

DESCRIPTION ^

 zAxisAngleRadians computes the axis and angle of rotation in an
 orthogonal matrix R

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % zAxisAngleRadians computes the axis and angle of rotation in an
0002 % orthogonal matrix R
0003 
0004 function [axis, angle] = zAxisAngleRadians(R)
0005 
0006 [v,d] = eig(R);                % get eigenvectors and values of R
0007 [y,i] = sort(imag(diag(d)));   % sort by imaginary part of eigenvalues
0008 
0009 axis  = v(:,i(2));             % eigenvector with eigenvalue 1, imag part 0
0010 
0011 [y,i] = sort(abs(axis));       % look for largest entries in axis
0012 
0013 b       =  zeros(3,1);         % b will be perpendicular to axis
0014 b(i(2)) =  axis(i(3));         % use the largest entries in axis
0015 b(i(3)) = -axis(i(2));
0016 
0017 angle = acos((b'*R*b) / (b'*b)) * sign(det([b R*b axis]));     
0018                                % angle of rotation, signed by rotation
0019                                % sense relative to axis of rotation

Generated on Fri 03-Apr-2009 09:52:35 by m2html © 2003