diff options
author | HakimOttey <hakimotteybusiness@gmail.com> | 2024-05-06 12:44:29 -0400 |
---|---|---|
committer | Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> | 2024-05-20 08:20:40 +0200 |
commit | 9dad7c0f1095e85ad40ad874215f1051137b0347 (patch) | |
tree | 11c64ddfeddfdd82c4f675d0fdadd50b2a4d0d32 | |
parent | ad3f86880bd6f5a0800a2820177715dc88c13a3c (diff) |
tdf#147906 implement hypot function for s1 x s1 + s2 x s2 statements
Change-Id: I50a2f4cf7738ee3797723929fb6840d2633c882c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166814
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
-rw-r--r-- | basegfx/source/curve/b2dcubicbezier.cxx | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 3f5d87aa79f6..31801db53559 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -22,9 +22,8 @@ #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/numeric/ftools.hxx> - #include <osl/diagnose.h> - +#include <cmath> #include <limits> // #i37443# @@ -645,15 +644,14 @@ namespace basegfx // now look for the closest point const sal_uInt32 nPointCount(aInitialPolygon.count()); B2DVector aVector(rTestPoint - aInitialPolygon.getB2DPoint(0)); - double fQuadDist(aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY()); + double fQuadDist(std::hypot(aVector.getX(), aVector.getY())); double fNewQuadDist; sal_uInt32 nSmallestIndex(0); for(sal_uInt32 a(1); a < nPointCount; a++) { aVector = B2DVector(rTestPoint - aInitialPolygon.getB2DPoint(a)); - fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY(); - + fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); if(fNewQuadDist < fQuadDist) { fQuadDist = fNewQuadDist; @@ -680,7 +678,7 @@ namespace basegfx aVector = B2DVector(rTestPoint - interpolatePoint(fPosLeft)); } - fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY(); + fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); if(fTools::less(fNewQuadDist, fQuadDist)) { @@ -702,7 +700,7 @@ namespace basegfx aVector = B2DVector(rTestPoint - interpolatePoint(fPosRight)); } - fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY(); + fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); if(fTools::less(fNewQuadDist, fQuadDist)) { @@ -727,7 +725,7 @@ namespace basegfx } rCut = fPosition; - return sqrt(fQuadDist); + return fQuadDist; } void B2DCubicBezier::split(double t, B2DCubicBezier* pBezierA, B2DCubicBezier* pBezierB) const |