Difference between angle2dcm and eul2rotm (same angle sequence, different result)

44 ビュー (過去 30 日間)
Gennaro Arguzzi
Gennaro Arguzzi 2018 年 12 月 23 日
コメント済み: Jan 2022 年 7 月 9 日
Hello everyone, I tried to use both functions angle2dcm and eul2rotm with the same angle sequence, but the results are different. Why?
I noticed that the two matrices are one the transpose of the other one, but what is the reason?
R=angle2dcm(-0.9277, -0.0553, -0.1741,'ZYX')
R=eul2rotm([-0.9277, -0.0553, -0.1741],'ZYX')
Thank you for your time.
  1 件のコメント
James Tursa
James Tursa 2022 年 7 月 8 日
編集済み: James Tursa 2022 年 7 月 8 日
angle2dcm( ) comes from the Aerospace Toolbox, which treats rotations as passive coordinate system transformations ('frame' in the doc). eul2rotm( ) comes from the Robotics Toolbox which treats rotations as active vector rotations ('point' in the doc). These two different conventions are essentially the inverse of each other. More discussion on these different toolbox conventions can be found here:

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

回答 (2 件)

Bruno Luong
Bruno Luong 2019 年 1 月 4 日
編集済み: Bruno Luong 2019 年 1 月 4 日
I check and the eul2rotm command returns the rotation matrix according to Wikipedia definition of euler z-y'-x" intrinsic to rotation matrix
thetaz = -0.9277; % yaw, psi
thetay = -0.0553; % pitch, theta
thetax = -0.1741; % roll, phi
Rx = makehgtform('xrotate',thetax); Rx = Rx(1:3,1:3);
Ry = makehgtform('yrotate',thetay); Ry = Ry(1:3,1:3);
Rz = makehgtform('zrotate',thetaz); Rz = Rz(1:3,1:3);
R = Rz*Ry*Rx
which is
R =
0.5988 0.7939 0.1060
-0.7990 0.5829 0.1474
0.0553 -0.1730 0.9834
This matrix is a Rotation matrix, that can be interpreted in 2 ways:
  1. Assuming you have a unrotate body (airplane) in the global (outside world) coordinates xyz := [x;y;z], when you apply R*xyz you'll fine the coordinates ot the rotated airplane yaw-pitch-roll with the right hand rule.
  2. Assuming you have a point/vector P in a local coordinates L = [lx;ly;lz] attached to the rotated-airplane, when you apply R, you'll find the global (outside world) coordinates G=[gx;gy;gz] of this point R*L = G.
For the same euler-angles, the angle2dcm command returns (as Jan pointed out) the transposed matrix T := R', which is also the inverse of R.
So the matrix T can be interpreted as the matrix when apply on a gobal coordinates G of a point P, you'll get the local coordinates L.
There are possibly different interpretation depending on the context. The best is to write down the mathematical formula instead of writing non-sense bla-bla as often with TMW document page.

Jan
Jan 2018 年 12 月 29 日
編集済み: Jan 2018 年 12 月 29 日
R1 = angle2dcm(-0.9277, -0.0553, -0.1741, 'ZYX')
R2 = eul2rotm([-0.9277, -0.0553, -0.1741], 'ZYX')
Do you see that R1 is the transpose of R2? This means, that both matrices create the "same" rotation, while one is applied to the vector and the other to the coordinate system. Or in other words, if the operation of rotating is applied to convert the original coordinate system to the transformed one, or the other way around.
There is no unique definition and each field of science uses other standards. So in biomechanics another convention is used than in aeronautics. This means that both R1 and R2 are correct, but it would be fine, if the documentation of both commands explain explicitly, what is replied.
  12 件のコメント
Paul
Paul 2022 年 7 月 8 日
編集済み: Paul 2022 年 7 月 8 日
FWIW, we have at least one data point that suggests Matlab does not use extrinsic rotations in any function in any toolbox: link to comment.
But we do have to worry about pre-muliplly by row vs. post-multiply by column, and frame vs. point rotation, which are also sometimes referred to as passive vs. active rotation.
I agree wholheartedly that the doc pages across the various toolboxes are inconsistent and confusing, as discussed in the entire thread of the linked comment.
For what it's worth, and it may not be much, my understanding is that angle2dcm produces a frame rotation (i.e., given the coordinates of a vector resolved in the "from" frame, find coordinates of the same vector resolved in the "to" frame) that pre-multiplies a column of coordinates and eul2rotm produces a frame rotation that post-multiplies a row of coordinates. For both functions 'ZYX' means the angle inputs to the functions are taken as first angle around Z, second around the subsequent Y, third around the subsequet X (same as the final X).
Jan
Jan 2022 年 7 月 9 日
I've seen flamewars in duscussion about the "right" order of rotations and signs of the angles. The problem is trivial from a mathematical point of view and a drama if persons discuss about it.I'm looking forward to seeing, that this discussion here keeps its focussed on the Matlab part.

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

カテゴリ

Help Center および File Exchange3-D Scene Control についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by