basegfx/source/curve/b2dcubicbezier.cxx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
New commits: commit 9dad7c0f1095e85ad40ad874215f1051137b0347 Author: HakimOttey <hakimotteybusin...@gmail.com> AuthorDate: Mon May 6 12:44:29 2024 -0400 Commit: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> CommitDate: Mon May 20 08:20:40 2024 +0200 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.lauhakan...@libreoffice.org> Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> 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