From 8f9049ddbcedbc1f623acb7bfcd2b31c286f4583 Mon Sep 17 00:00:00 2001 From: Inho Lee Date: Tue, 19 Apr 2022 11:30:19 +0200 Subject: [PATCH] Update comments in QQuaternion::getEulerAngles A comment from the patch 6ffc8d8eb6c44fbd51e37770e7013c4610ead96d is a little ambiguous. This patch is just to give information about the modification. Task-number: QTBUG-72103 Pick-to: 6.3 6.2 5.15 Change-Id: I6bfc3ae926c118de0d969a4b44f438c24f8d4f72 Reviewed-by: Edward Welbourne --- src/gui/math3d/qquaternion.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 93e396c5a1c..2f12accc412 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -495,8 +495,9 @@ void QQuaternion::getEulerAngles(float *pitch, float *yaw, float *roll) const // https://ingmec.ual.es/~jlblanco/papers/jlblanco2010geometry3D_techrep.pdf // "A tutorial on SE(3) transformation parameterizations and on-manifold optimization". - // Normalize values even if the length is below the margin. Otherwise we might fail - // to detect Gimbal lock due to cumulative errors. + // We can only detect Gimbal lock when we normalize, which we can't do when + // length is nearly zero. Do so before multiplying co-ordinates, to avoid + // underflow. const float len = length(); const bool rescale = !qFuzzyIsNull(len); const float xps = rescale ? xp / len : xp;