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

40 views (last 30 days)
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 Comment
James Tursa
James Tursa on 8 Jul 2022
Edited: James Tursa on 8 Jul 2022
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:

Sign in to comment.

Answers (2)

Bruno Luong
Bruno Luong on 4 Jan 2019
Edited: Bruno Luong on 4 Jan 2019
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 on 29 Dec 2018
Edited: Jan on 29 Dec 2018
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 Comments
Paul
Paul on 8 Jul 2022
Edited: Paul on 8 Jul 2022
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 on 9 Jul 2022
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.

Sign in to comment.

Categories

Find more on 3-D Scene Control in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!