what's the code inside angle2dcm?

15 ビュー (過去 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.
  1 件のコメント
yunya liu
yunya liu 2022 年 4 月 28 日
Thank you

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by