summaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview/boxes/trackball.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-01-14 11:17:47 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-02-16 16:21:15 +0000
commit515e802ae20c045e5c47b400ee6ef6e92349c978 (patch)
treef9f4be4c9e360611b5823ef28c2cb293733aee42 /examples/widgets/graphicsview/boxes/trackball.cpp
parent3d835eb62e70435fe32318441dc7c10aba3a6fba (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 'examples/widgets/graphicsview/boxes/trackball.cpp')
-rw-r--r--examples/widgets/graphicsview/boxes/trackball.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/widgets/graphicsview/boxes/trackball.cpp b/examples/widgets/graphicsview/boxes/trackball.cpp
index 2267636fa4..b1159b4989 100644
--- a/examples/widgets/graphicsview/boxes/trackball.cpp
+++ b/examples/widgets/graphicsview/boxes/trackball.cpp
@@ -33,6 +33,7 @@
#include "trackball.h"
#include "scene.h"
+#include <cmath>
//============================================================================//
// TrackBall //
@@ -94,19 +95,19 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation)
QVector3D lastPos3D = QVector3D(m_lastPos.x(), m_lastPos.y(), 0.0f);
float sqrZ = 1 - QVector3D::dotProduct(lastPos3D, lastPos3D);
if (sqrZ > 0)
- lastPos3D.setZ(sqrt(sqrZ));
+ lastPos3D.setZ(std::sqrt(sqrZ));
else
lastPos3D.normalize();
QVector3D currentPos3D = QVector3D(p.x(), p.y(), 0.0f);
sqrZ = 1 - QVector3D::dotProduct(currentPos3D, currentPos3D);
if (sqrZ > 0)
- currentPos3D.setZ(sqrt(sqrZ));
+ currentPos3D.setZ(std::sqrt(sqrZ));
else
currentPos3D.normalize();
m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D);
- float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis)));
+ float angle = 180 / PI * std::asin(std::sqrt(QVector3D::dotProduct(m_axis, m_axis)));
m_angularVelocity = angle / msecs;
m_axis.normalize();