diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-08-16 20:37:09 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-08-16 20:37:09 +0300 |
commit | b7d91087099e4b69d70c0271fbeae19368d485d4 (patch) | |
tree | f46b62227cfeccf32b72f6aeb45c17cc7a933505 /src/gui/math3d/qquaternion.cpp | |
parent | 231d3670981a33ec42b91ad1cb33c1fc50551066 (diff) | |
parent | bbfbb18df18658e8ceec4bc04bd2cdf59f6a35ed (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.6' into tqtc/lts-5.15-opensource
Change-Id: Ia9164a17d80376f0a3ab9752c4a9f4dd2f0bd3d9
Diffstat (limited to 'src/gui/math3d/qquaternion.cpp')
-rw-r--r-- | src/gui/math3d/qquaternion.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 5f15949c5b..67f013c82e 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -534,7 +534,11 @@ void QQuaternion::getEulerAngles(float *pitch, float *yaw, float *roll) const zw /= lengthSquared; } - *pitch = std::asin(-2.0f * (yz - xw)); + const float sinp = -2.0f * (yz - xw); + if (std::abs(sinp) >= 1.0f) + *pitch = std::copysign(M_PI_2, sinp); + else + *pitch = std::asin(sinp); if (*pitch < M_PI_2) { if (*pitch > -M_PI_2) { *yaw = std::atan2(2.0f * (xz + yw), 1.0f - 2.0f * (xx + yy)); |