what's the code inside angle2dcm?

조회 수: 33 (최근 30일)
yunya liu
yunya liu 2022년 4월 27일
댓글: yunya liu 2022년 4월 28일
I saw angle2dcm on Mathworks but don't know how scalars of x,y,z or vectors of x,y,z become matrix after using angle2dcm.
Can anyone explain the code embedded?
Thanks very much.

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 4월 27일
hello
here you are
notice that there are some issues / questions about orientation convention with this function
function [dcm] = angle2dcm(r,seq)
% dcm = angle2dcm(r1,r2,r3,seq)
% builds euler angle rotation matrix
%
% r = [r1 r2 r3]
% seq = 'ZYX' (default)
% 'ZXZ'
% dcm = direction cosine matrix
if nargin == 1
seq = 'ZYX';
end
switch seq
case 'ZYX'
dcm = Tx(r(3))*Ty(r(2))*Tz(r(1));
case 'ZXZ'
dcm = Tz(r(3))*Tx(r(2))*Tz(r(1));
end
function A = Tx(a)
A = [1 0 0;0 cosd(a) sind(a);0 -sind(a) cosd(a)];
function A = Ty(a)
A = [cosd(a) 0 -sind(a);0 1 0;sind(a) 0 cosd(a)];
function A = Tz(a)
A = [cosd(a) sind(a) 0;-sind(a) cosd(a) 0;0 0 1];
  댓글 수: 1
yunya liu
yunya liu 2022년 4월 28일
Very detailed description. Thanks so much.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2022년 4월 27일
While I cannot find the code of angle2dcm , the equivalent function eul2rotm is useful for the explanation also. It produces the transposed matrix compared to angle2dcm.
See:
edit eul2rotm
3 angles define the attitude of a coordinate system. The "dcm" matrix (direction cosine matrix) contains the 3 unit vectors of the base of a rotated coordinate system.

카테고리

Help CenterFile Exchange에서 Axes Transformations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by