diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-01-14 11:17:47 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-02-16 16:21:15 +0000 |
commit | 515e802ae20c045e5c47b400ee6ef6e92349c978 (patch) | |
tree | f9f4be4c9e360611b5823ef28c2cb293733aee42 /src/corelib/tools/qeasingcurve.cpp | |
parent | 3d835eb62e70435fe32318441dc7c10aba3a6fba (diff) |
Use C++ <cmath> instead of <math.h>
Including math.h can pollute the default namespace, and break
some compilers if cmath versions of the method are declared as using.
Switching to C++ math functions also greatly simplifies handling of
float qreal as C++ automatically chooses the right method.
[ChangeLog][QtCore][QtMath] qmath.h no longer includes math.h, so any
sources depending on that indirect inclusion may fail to build.
Change-Id: I4d0e331dafba354ec05dc5052e61ef4ff8d387fe
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/corelib/tools/qeasingcurve.cpp')
-rw-r--r-- | src/corelib/tools/qeasingcurve.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index c1d74b3b43..1bd9c5ebb9 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -657,7 +657,7 @@ struct BezierEase : public QEasingCurveFunction qreal static inline _acos(qreal x) { - return sqrt(1-x)*(1.5707963267948966192313216916398f + x*(-0.213300989f + x*(0.077980478f + x*-0.02164095f))); + return std::sqrt(1-x)*(1.5707963267948966192313216916398f + x*(-0.213300989f + x*(0.077980478f + x*-0.02164095f))); } qreal static inline _cos(qreal x) //super fast _cos @@ -704,8 +704,8 @@ struct BezierEase : public QEasingCurveFunction //We use approximations instead const qreal x_squared = x * x; - const qreal x_plus_one_sqrt = sqrt(1.0 + x); - const qreal one_minus_x_sqrt = sqrt(1.0 - x); + const qreal x_plus_one_sqrt = qSqrt(1.0 + x); + const qreal one_minus_x_sqrt = qSqrt(1.0 - x); //cos(acos(x) / 3) //s1 = _cos(_acos(x) / 3); @@ -743,7 +743,7 @@ struct BezierEase : public QEasingCurveFunction const qreal D = 0.25 * q_squared + p_cubic / 27.0; if (D >= 0) { - const qreal D_sqrt = sqrt(D); + const qreal D_sqrt = qSqrt(D); qreal u = _cbrt( -q * 0.5 + D_sqrt); qreal v = _cbrt( -q * 0.5 - D_sqrt); qreal z1 = u + v; @@ -758,13 +758,13 @@ struct BezierEase : public QEasingCurveFunction } //casus irreducibilis - const qreal p_minus_sqrt = sqrt(-p); + const qreal p_minus_sqrt = qSqrt(-p); //const qreal f = sqrt(4.0 / 3.0 * -p); - const qreal f = sqrt(4.0 / 3.0) * p_minus_sqrt; + const qreal f = qSqrt(4.0 / 3.0) * p_minus_sqrt; //const qreal sqrtP = sqrt(27.0 / -p_cubic); - const qreal sqrtP = -3.0*sqrt(3.0) / (p_minus_sqrt * p); + const qreal sqrtP = -3.0*qSqrt(3.0) / (p_minus_sqrt * p); const qreal g = -q * 0.5 * sqrtP; |