필터 지우기
필터 지우기

Why does conversion from quaternions to rotation angles followed by rotation angles to quaternions give different results in Aerospace Toolbox 2.2(R2008b)?

조회 수: 2 (최근 30일)
I have a simple example which converts a quaternion to rotational angles and then reconverts it back to quaternion. The reproduction code is as follows:
q=[1 0 1 0];
[yaw, pitch, roll] = quat2angle(q)
q2 = angle2quat(yaw, pitch, roll)
Output (q2) is [0.7071 0 0.7071 0] whereas the input (q) was [1 0 1 0]. I expected q2 to be same as q.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
This is an expected behavior in Aerospace Toolbox 2.2(R2008b) in the way the quaternion to rotational angle conversion is executed.
When a call is made to QUAT2ANGLE, q is normalized internally using the QUATNORMALIZE function. The input q is changed to qin (q/norm(q)).
However, when a call is made using the ANGLE2QUAT to reconvert the rotational angles back to quaternions, the denormalization is not done. Hence, the output 'q' is does not appear same as input 'q' but it is actually the normalized version of 'q' (qin).
As a workaround, one can denormalize the ouput to match the input.
q=[1 0 1 0];
[yaw, pitch, roll] = quat2angle(q)
q2 = angle2quat(yaw, pitch, roll)
q3 = q2*norm(q);
Output (q3) is now [1 0 1 0] , same as the input (q) was [1 0 1 0].

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Unit Conversions에 대해 자세히 알아보기

제품


릴리스

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by