1-2-1 or X-Y-X rotation matrix not supported

9 visualizaciones (últimos 30 días)
SE
SE el 20 de Dic. de 2019
Comentada: SE el 2 de En. de 2020
Hi all,
I want to convert from euler to quaternion with 1-2-1 (respectively X-Y-X) rotation.
However, Matlab is not supporting this, is there a way to go around this?

Respuesta aceptada

James Tursa
James Tursa el 20 de Dic. de 2019
According to the doc here:
The angle2quat supports the 'XYX' sequence. What functions are you using?
  3 comentarios
James Tursa
James Tursa el 20 de Dic. de 2019
Editada: James Tursa el 20 de Dic. de 2019
Can you use the angle2quat( ) function from the Aerospace Toolbox instead? A bit strange that eul2quat( ) has this limitation when other functions in MATLAB do not. Maybe should submit an enhancement request to MathWorks for this oversight. The quat2eul( ) function also has this limitation.
Another option is to use a utility like SpinCalc by John Fuller that can be found in the FEX:
But if you use SpinCalc, be aware that it will return quaternions in Vector-Scalar order. Whereas the MATLAB toolbox functions work with quaternions in Scalar-Vector order. So you would need to manually adjust the result of SpinCalc to put it into the MATLAB convention. E.g.,
>> angdeg = [10,20,30];
>> angrad = angdeg*pi/180;
>> qsv = angle2quat(angrad(1),angrad(2),angrad(3),'XYX')
qsv =
0.925416578398323 0.336824088833465 0.171010071662834 -0.030153689607046
>> qvs = SpinCalc('EA121toQ',angdeg)
qvs =
0.336824088833465 0.171010071662834 -0.030153689607046 0.925416578398323
>> [qvs(4),qvs(1:3)]
ans =
0.925416578398323 0.336824088833465 0.171010071662834 -0.030153689607046
>> SpinCalc('QtoEA121',qvs,1e-10,0)
ans =
10.000000000000002 19.999999999999993 30.000000000000004
SE
SE el 2 de En. de 2020
Can you use the angle2quat( ) function from the Aerospace Toolbox instead?
--> this actually did the job, thanks!

Iniciar sesión para comentar.

Más respuestas (2)

Matt J
Matt J el 20 de Dic. de 2019
Editada: Matt J el 20 de Dic. de 2019
You could compose the rotation matrix and use rotm2quat.
function quat = xyx2quat(eul)
Rx = @(x) [1, 0, 0;...
0, cos(x), -sin(x);...
0, sin(x), cos(x) ];
Ry= @(x) [cos(x), 0, sin(x); 0 1 0; -sin(x), 0, cos(x) ];
rotm=Rx(eul(3))*Ry(eul(2))*Rx(eul(1));
quat = rotm2quat(rotm);
end
  1 comentario
James Tursa
James Tursa el 20 de Dic. de 2019
There is a subtle difference here. In the MATLAB toolbox code and in the SpinCalc code, the assumption is that the angles represent the relationship between coordinate frames, whereas using the code above assumes the angles represent a vector rotation within the same coordinate frame. This difference results in the "opposite" sense of rotation. E.g., using the method above:
>> angles = [10,20,30];
>> rotm=Rx(angles(3))*Ry(angles(2))*Rx(angles(1));
>> quat = rotm2quat(rotm)
quat =
0.925416578398323 0.336824088833465 0.171010071662834 0.030153689607046
You can see that the last element has the opposite sign as the results using the angle2quat( ) and SpinCalc( ) functions. To get the same result as these functions, where the angles represent a rotation of the coordinate frames instead of a vector rotation, you need to reverse the order of the rotations with this method. E.g.,
>> rotm=Rx(angles(1))*Ry(angles(2))*Rx(angles(3));
>> quat = rotm2quat(rotm)
quat =
0.925416578398323 0.336824088833465 0.171010071662834 -0.030153689607046
Now you can see that the last element has the same sign as the result from angle2quat( ) and SpinCalc( ).

Iniciar sesión para comentar.


Jim Riggs
Jim Riggs el 20 de Dic. de 2019
Editada: Jim Riggs el 20 de Dic. de 2019
I recently cataloged all of the permutations of the 2 and 3 axis planar rotations.
It is easy to write your own functions.
See the attached paper for the method equations, the section on "Repeated Angle Rotations".
Here is an exerpt from the paper:
See the paper for the definition of "direct" and "inverse" rotations. It effects the interpretation of the signs of the angles.
Once you calculate the Direction Cosine Matrix, you can convert it to a quaternion or a rotation vector.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by