what's the code inside angle2dcm?
조회 수: 33 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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개)
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 Center 및 File Exchange에서 Axes Transformations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!