diff options
-rw-r--r-- | src/particles/qquicktargetdirection.cpp | 2 | ||||
-rw-r--r-- | tests/manual/v4/v8-bench.js | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/particles/qquicktargetdirection.cpp b/src/particles/qquicktargetdirection.cpp index 0a0eeb4a24..5aa813be6f 100644 --- a/src/particles/qquicktargetdirection.cpp +++ b/src/particles/qquicktargetdirection.cpp @@ -123,7 +123,7 @@ QPointF QQuickTargetDirection::sample(const QPointF &from) qreal theta = std::atan2(targetY, targetX); qreal mag = m_magnitude + QRandomGenerator::global()->generateDouble() * m_magnitudeVariation * 2 - m_magnitudeVariation; if (m_proportionalMagnitude) - mag *= std::sqrt(targetX * targetX + targetY * targetY); + mag *= qHypot(targetX, targetY); ret.setX(mag * std::cos(theta)); ret.setY(mag * std::sin(theta)); return ret; diff --git a/tests/manual/v4/v8-bench.js b/tests/manual/v4/v8-bench.js index bfce6231e4..33f39688c2 100644 --- a/tests/manual/v4/v8-bench.js +++ b/tests/manual/v4/v8-bench.js @@ -3645,6 +3645,7 @@ Flog.RayTracer.Vector.prototype = { }, magnitude : function() { + // return Math.hypot(this.x, this.y, this.z); but keep results Qt5-comparable: return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z)); }, |