From 8095c33bcddefebd16b7cb08b07690caf877f600 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 21 Feb 2017 17:14:37 +0100 Subject: Use qRadiansToDegrees() and qDegreesToRadians() more widely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Especially in examples, where we should show off our convenience functions, prefer calling these functions over doing arithmetic with M_PI (or approximations thereto) and 180 (give or take simple factors). This incidentally documents what's going on, just by the name of the function used (and reveals at least one place where variables were misnamed; the return from atan is in radians, *not* degrees). Task-number: QTBUG-58083 Change-Id: I6e5d66721cafab423378f970af525400423e971e Reviewed-by: Jüri Valdmann Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Marc Mutz --- src/gui/math3d/qquaternion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/math3d/qquaternion.cpp') diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index e3262c8830..fe1b0425a8 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -408,7 +408,7 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, float angle) // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56 // We normalize the result just in case the values are close // to zero, as suggested in the above FAQ. - float a = (angle / 2.0f) * M_PI / 180.0f; + float a = qDegreesToRadians(angle / 2.0f); float s = std::sin(a); float c = std::cos(a); QVector3D ax = axis.normalized(); @@ -467,7 +467,7 @@ QQuaternion QQuaternion::fromAxisAndAngle y /= length; z /= length; } - float a = (angle / 2.0f) * M_PI / 180.0f; + float a = qDegreesToRadians(angle / 2.0f); float s = std::sin(a); float c = std::cos(a); return QQuaternion(c, x * s, y * s, z * s).normalized(); -- cgit v1.2.3