DCM2ANGVEC facilitates the use of the function dcm2angle. DCM2ANGVEC facilitates the use of the function dcm2angle. The function outputs the Euler angles of the rotation matrix phi. CONVENTION: Let Ri be the rotation matrix that rotates the 'axes' about axis i. Then phi=Rz*Ry*Rx. See angvec2dcm for further details. USAGE: rot=dcm2angvec(phi); INPUTS: phi: 3x3 rotation matrix. OUTPUTS: rot: 3x1 Euler angles vector Abdallah Kassir 1/3/2010
0001 function rot=dcm2angvec(phi) 0002 % DCM2ANGVEC facilitates the use of the function dcm2angle. 0003 % 0004 % DCM2ANGVEC facilitates the use of the function dcm2angle. 0005 % The function outputs the Euler angles of the rotation matrix phi. 0006 % 0007 % CONVENTION: 0008 % Let Ri be the rotation matrix that rotates the 'axes' about axis i. 0009 % Then phi=Rz*Ry*Rx. See angvec2dcm for further details. 0010 % 0011 % 0012 % USAGE: 0013 % rot=dcm2angvec(phi); 0014 % INPUTS: 0015 % phi: 3x3 rotation matrix. 0016 % 0017 % OUTPUTS: 0018 % rot: 3x1 Euler angles vector 0019 % 0020 % Abdallah Kassir 1/3/2010 0021 0022 % [rx,ry,rz]=dcm2angle(phi,'xyz'); % requires aerospace toolbox 0023 % rot=[rx;ry;rz]; 0024 0025 if phi(3,1)~=1 && phi(3,1)~=-1 0026 ry=asin(phi(3,1)); 0027 rz=atan2(-phi(2,1)/cos(ry),phi(1,1)/cos(ry)); 0028 rx=atan2(-phi(3,2)/cos(ry),phi(3,3)/cos(ry)); 0029 else 0030 rz=0; 0031 ry=asin(phi(3,1)); 0032 if phi(3,1)==1 0033 rx=atan2(phi(1,2)/phi(3,1),-phi(1,3)/phi(3,1)); 0034 elseif phi(3,1)==-1 0035 rx=-atan2(phi(1,2)/phi(3,1),-phi(1,3)/phi(3,1)); 0036 end 0037 end 0038 rot=[rx;ry;rz]; 0039 end 0040