diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2017-02-21 17:14:37 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2017-07-05 10:15:34 +0000 |
commit | 8095c33bcddefebd16b7cb08b07690caf877f600 (patch) | |
tree | 816731835b77eb798295c4324f95b23f9916ebef /tests/auto/gui/painting/qwmatrix | |
parent | 827e53540c8de10f3a0b8548523ca80bf9e1c75b (diff) |
Use qRadiansToDegrees() and qDegreesToRadians() more widely
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 <juri.valdmann@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/gui/painting/qwmatrix')
-rw-r--r-- | tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp index 46420b49c5..da88a868f3 100644 --- a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp +++ b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp @@ -114,12 +114,8 @@ void tst_QWMatrix::mapping_data() << QRect( 0, 0, 30, 40 ) << QPolygon( QRect( -300, -400, 300, 400 ) ); -#if defined(Q_OS_WIN) && !defined(M_PI) -#define M_PI 3.14159265897932384626433832795f -#endif - const auto rotate = [](qreal degrees) { - const qreal rad = M_PI * degrees / 180.; + const qreal rad = qDegreesToRadians(degrees); return QMatrix(std::cos(rad), -std::sin(rad), std::sin(rad), std::cos(rad), 0, 0); }; @@ -140,7 +136,7 @@ void tst_QWMatrix::mapping_data() #if 0 const auto rotScale = [](qreal degrees, qreal scale) { - const qreal rad = M_PI * degrees / 180.; + const qreal rad = qDegreesToRadians(degrees); return QMatrix(scale * std::cos(rad), -scale * std::sin(rad), scale * std::sin(rad), scale * std::cos(rad), 0, 0); }; |