Deploy qHypot() to eliminate sqrt(sum of squares)
Applies to QDoubleMatrix4x4, QDoubleVector2D, QDoubleVector3D.
Summing squares and then taking the square root has some
{ov,und}erflow failures when the squares are logarithmically beyond
about half way to the bounds of the representable values of the type.
A hypot() implementation - such as qHypot(), which copes with
arbitrarily many parameters - takes care to avoid those failures,
thereby producing finite non-zero answers for a broader range of
vectors. Using hypot() also preserves precision better, for related
reasons, and handles infinities and NaN more coherently, should they
arise.
In the process, reverse some qFuzzyCompare() || qFuzzyIsNull() checks
so that the is-null check is done first, satisfying the precondition
of the comparison (neither argument should be zero) before it is
reached.
Task-number: QTBUG-142020
Pick-to: 6.11 6.10 6.8 6.5
Change-Id: I34eb88a5e518155ab7c4584ec07a20404a1c0eb5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>