diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2017-03-22 14:18:02 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-07-07 18:09:08 +0000 |
commit | 3a9e135d5561ddbc8b6664f5aadf58fd07b02ec1 (patch) | |
tree | 0029a2a70063a6b0d1af1c754fe2150477d59cd3 /examples/widgets | |
parent | fcb423d1f25bd3e283c2023d988ed54921fcd12d (diff) |
Exploit QVector3D::length() instead of duplicating its work
Calling the class-method dotProduct(x, x) in order to then take its
square root is a clumsy way to obfuscate x.length() - and lacks its
efforts (clumsy though they are) to limit rounding issues.
Change-Id: I1dc1f38764651bc70c0620e286cb5625f505ddbf
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/graphicsview/boxes/trackball.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/widgets/graphicsview/boxes/trackball.cpp b/examples/widgets/graphicsview/boxes/trackball.cpp index c350f6adee..794ce7ac37 100644 --- a/examples/widgets/graphicsview/boxes/trackball.cpp +++ b/examples/widgets/graphicsview/boxes/trackball.cpp @@ -126,7 +126,7 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation) currentPos3D.normalize(); m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D); - float angle = qRadiansToDegrees(std::asin(std::sqrt(QVector3D::dotProduct(m_axis, m_axis)))); + float angle = qRadiansToDegrees(std::asin(m_axis.length())); m_angularVelocity = angle / msecs; m_axis.normalize(); |