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
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 个)

产品


版本

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by