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>
This commit is contained in:
parent
fcb423d1f2
commit
3a9e135d55
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user