summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d/qvector4d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/math3d/qvector4d.cpp')
-rw-r--r--src/gui/math3d/qvector4d.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 1691a6d..e4b2b82 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -285,11 +285,11 @@ void QVector4D::normalize()
return;
len = qSqrt(len);
-
- xp /= len;
- yp /= len;
- zp /= len;
- wp /= len;
+ const double inv_len = 1 / len;
+ xp *= inv_len;
+ yp *= inv_len;
+ zp *= inv_len;
+ wp *= inv_len;
}
/*!
@@ -459,7 +459,8 @@ QVector2D QVector4D::toVector2DAffine() const
{
if (qIsNull(wp))
return QVector2D();
- return QVector2D(xp / wp, yp / wp, 1);
+ const qreal inv_wp = 1 / wp;
+ return QVector2D(xp * inv_wp, yp * inv_wp, 1);
}
#endif
@@ -486,7 +487,8 @@ QVector3D QVector4D::toVector3DAffine() const
{
if (qIsNull(wp))
return QVector3D();
- return QVector3D(xp / wp, yp / wp, zp / wp, 1);
+ const qreal inv_wp = 1 / wp;
+ return QVector3D(xp * inv_wp, yp * inv_wp, zp * inv_wp, 1);
}
#endif