wyh rotation matrix convert to eular angle is not same with original eular?

At the beginning,i use eul2rotm function to convert eular degree to rotation matrix,then use rotm2eul function convert to back ,but it not same as before,why it occur like this result,i don't it understand. Thanks in advance!
eular1 = [pi/2,pi,-pi/2] % ZYX default order
eular1 = 1×3
1.5708 3.1416 -1.5708
r = eul2rotm(eular1,'ZYX');
eular2 = rotm2eul(r,'ZYX')
eular2 = 1×3
-1.5708 0.0000 1.5708
eular2 is not same eular1?

 Accepted Answer

It is the same, because eul2rotm is not a 1-1 function.
eular1 = [pi/2,pi,-pi/2]; % ZYX default order
r = eul2rotm(eular1,'ZYX')
r = 3×3
-0.0000 -0.0000 -1.0000 -1.0000 -0.0000 0.0000 -0.0000 1.0000 -0.0000
eular2 = rotm2eul(r,'ZYX');
r2=eul2rotm(eular2,'ZYX')
r2 = 3×3
-0.0000 -0.0000 -1.0000 -1.0000 -0.0000 0.0000 -0.0000 1.0000 -0.0000

7 Comments

you mean eular1 and eular2 are difference of 2*pi radians in period is same? but i change eular1 orther values, they are not defference of 2*pi radians,for example:
eular1 = [pi/2,-pi/2,2*pi]
eular1 = 1×3
1.5708 -1.5708 6.2832
r = eul2rotm(eular1,'ZYX');
eular2 = rotm2eul(r,'ZYX')
eular2 = 1×3
0 -1.5708 1.5708
No, but the calculation of the rotation matrix involves a lot of trig operations that are not 1-1,
Does it matter? You can see from my post that eular2 corresponds to the same rotation matrix as eular1.
Hi @cui
In a simple explanation, both rotational sequences result in the same orientation that is defined by the rotation matrix.
To give you a simple example, one rotation axis is used. Rotating 45° and 405° anticlockwise are the same as rotating 315° clockwise.
However, physically, you would want to make the minimum rotations in order to save energy.
@Sam Chak Thank you for the explanation. It helps understand it better.
With this in mind, is there a way to minimize the two representations (eular1 and eular2) to come to a common minimum rotation?
You must apply the torque to rotate from one orientation to another. To achieve the minimum rotation, this implies that you need to apply the minimum torque.
You can derive a formula to compute the optimal torque needed, through the rigorous mathematics route.
Or you can take the AI/ML route to automatically find just the right torque, with a click of a button without knowing the math of the system and the torque actuator. You need to define the Cost/Objective Function though.

Sign in to comment.

More Answers (0)

Products

Release

R2022a

Asked:

on 10 May 2022

Edited:

on 29 Oct 2022

Community Treasure Hunt

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

Start Hunting!