diff options
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 440ed3c99b..86e7d8ce62 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -527,7 +527,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)); |