Hi!
I have been trying to look for a function that will "undo" a transformation matrix.
I saw in Matlab that there's a function "makehgtform" to create a transformation matrix. Now, I'm looking for something that is the exact opposite of this.
Example:
M = makehgtform('xrotate',30*pi/180);
It would result to a 4x4 matrix. But I want to actually extract the X, Y, Z translation and X,Y,Z rotation.
Can anyone help me or just give me an idea? I would really appreciate it! :(
Thanks in advance!

 채택된 답변

Matt J
Matt J 2018년 11월 28일
편집: Matt J 2018년 11월 28일

2 개 추천

Here's an example that makes use of the attached file for rotation matrix decomposition.
>> M = makehgtform('translate',[1,2,3],'xrotate',30*pi/180)
M =
1.0000 0 0 1.0000
0 0.8660 -0.5000 2.0000
0 0.5000 0.8660 3.0000
0 0 0 1.0000
>> translation=M(1:3,end)
translation =
1
2
3
>> rotation=rot2taitbryan(M(1:3,1:3),'xyz'), %see attached file
rotation =
30.0000 0 0

댓글 수: 9

Kash Costello
Kash Costello 2018년 11월 28일
Hi omg you are a life saver! Yes, I know that the translation is the last column and the rotation matrix is the first 3x3 but I didn't think of actually... processing them separately. -facepalm- Anyway, I saw the matlab function! Is it possible to NOT use the function you created? Like, just use any built-in commands in matlab?
I tried to use this:
M = makehgtform('translate',[1,2,3],'xrotate',30*pi/180);
M2 = M(1:3,1:3);
translation = M(1:3,end);
eul = rotm2eul(M2,'ZYX');
eul1 = eul.*(180/pi);
eul2 = fliplr(eul1);
It gave me --> 30.0000,0,0 just like what I want. But when I tried to put
'yrotate',30*pi/180
It's giving me --> 33.6901,25.6589,33.6901
Do you have any idea what happened on this one? Thanks a lot!!
Matt J
Matt J 2018년 11월 28일
You can extract the lines of code from rot2taitbryan.m that are relevant to you, if you wish. I do not know what conventions rotm2eul uses and cannot play around with it, since I do not have the Robotics System Toolbox.
Kash Costello
Kash Costello 2018년 11월 28일
Okay, that's fine. Thanks so so so much! I really appreciate your help and the code you shared. It helped me a lot!!
Kash Costello
Kash Costello 2018년 11월 28일
Oh uh by the way... if it's not too much to ask, could you explain (perhaps with an example?) why you wrote the function that way? I'm watching videos but I'm still kind of confused. If it's not okay, I totally understand. Thanks again! Have a good day!
Matt J
Matt J 2018년 11월 28일
It's not mine. I downloaded it from somewhere.
Kash Costello
Kash Costello 2018년 11월 28일
Oh. Okay, but do you at least know why the sequence is like this?
case 'XYZ'
ang(1) = atan2d(-R(2,3),R(3,3));
ang(2) = asind(R(1,3));
ang(3) = atan2d(-R(1,2),R(1,1));
I understand why it's R(2,3), R(3,3) and such. But I am confused why it's -R(2,3) first and why not R(3,3).
Bruno Luong
Bruno Luong 2018년 11월 28일
편집: Bruno Luong 2018년 11월 28일
Oh. Okay, but do you at least know why the sequence is like this?
Kash Costello
Kash Costello 2018년 11월 28일
Ok I'm being an idiot but I'm still confused even after reading that document. I guess I don't fully grasp what atan2 is and still, it didn't explain why the sequence is like that. My question still remains... :(
Matt J
Matt J 2018년 11월 28일
편집: Matt J 2018년 11월 28일
I guess I don't fully grasp what atan2 is

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bruno Luong
Bruno Luong 2018년 11월 28일

0 개 추천

Translation vector is T(1:3,4);
Rotation matrix is T(1:3,1:3).
If you want to decompose in rotation on axis, there are many conventions (intrinsic, extrinsic, Euler's angle, Tait–Bryan angles, etc...) see https://en.wikipedia.org/wiki/Euler_angles and pick your choice.

카테고리

도움말 센터File Exchange에서 Coordinate Transformations에 대해 자세히 알아보기

질문:

2018년 11월 28일

편집:

2018년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by