Difference between angle2dcm and eul2rotm (same angle sequence, different result)
61 次查看(过去 30 天)
显示 更早的评论
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199643/image.jpeg)
Thank you for your time.
1 个评论
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
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:
- 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.
- 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.
0 个评论
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
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
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 Exchange 中查找有关 Coordinate Systems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!