Difference between angle2dcm and eul2rotm (same angle sequence, different result)
조회 수: 39 (최근 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')
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에서 3-D Scene Control에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!