summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInho Lee <inho.lee@qt.io>2022-04-19 11:30:19 +0200
committerInho Lee <inho.lee@qt.io>2023-02-03 15:05:28 +0100
commit1e5ae32c5596d598f7e6305613e12c044ea925a8 (patch)
treeb65925ead99f3192c1f50d64c94759314abad813
parente2bc6e02755845f8cd754e01d15df1f7e6d17e3a (diff)
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 Change-Id: I6bfc3ae926c118de0d969a4b44f438c24f8d4f72 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 8f9049ddbcedbc1f623acb7bfcd2b31c286f4583)
-rw-r--r--src/gui/math3d/qquaternion.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 7145330cfd..c389b246d9 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -512,8 +512,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;