what's the code inside angle2dcm?

15 visualizaciones (últimos 30 días)
yunya liu
yunya liu el 27 de Abr. de 2022
Comentada: yunya liu el 28 de Abr. de 2022
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.

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 27 de Abr. de 2022
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 comentario
yunya liu
yunya liu el 28 de Abr. de 2022
Very detailed description. Thanks so much.

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 27 de Abr. de 2022
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.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by