2025-04-23 11:22:45 +08:00

23 lines
931 B
Matlab
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function [Cb2n_312, Cb2n_321] = eul2m(att)
% 将欧拉角转换为姿态阵
% 复用严龚敏老师的a2mat
%
% Input: att 单位rad
% 对于312((Z->X->Y))顺序对应att = [pitch(绕X轴) roll(绕Y轴) yaw(绕Z轴)]
% 对于3211(Z->Y->X)顺序对应att = [roll(绕X轴) pitch(绕Y轴) yaw(绕Z轴)]
% Outputs:
% Cb2n_312: 312欧拉角顺序下转换后的Cb2n
% Cb2n_321: 321欧拉角顺序下转换后的Cb2n
s = sin(att); c = cos(att);
si = s(1); sj = s(2); sk = s(3);
ci = c(1); cj = c(2); ck = c(3);
Cb2n_312 = [ cj*ck-si*sj*sk, -ci*sk, sj*ck+si*cj*sk;
cj*sk+si*sj*ck, ci*ck, sj*sk-si*cj*ck;
-ci*sj, si, ci*cj ];
if nargout==2 % dual Euler angle DCM
Cb2n_321 = [ cj*ck, si*sj*ck-ci*sk, ci*sj*ck+si*sk;
cj*sk, si*sj*sk+ci*ck, ci*sj*sk-si*ck;
-sj, si*cj, ci*cj ];
end