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 Center および File ExchangeUnit Conversions についてさらに検索

製品


リリース

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by