From 6419ecb40a025f1b4f7df5d059bfca3579dab4d7 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 15 Sep 2021 12:34:12 +0200 Subject: [PATCH] No need to check if nDX is 0 for atan2 We rely on IEEE floating-point arithmetic anyway, and then even both arguments equal to 0 do not result in an error. Even if it was different, it would be better to check id both nDX and nDY are 0, and return 0 early. It was so ever since "MWS_SRX644: migrate branch mws_srx644 -> HEAD" commit fd2cf3dc7cd9c73070fa4d70c8ca99c9fc1ce135. Change-Id: I5b8e2a359374dd1500b149d74eba4c0b0e5cd8d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122115 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- tools/source/generic/poly.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 70bafc824404..ab33eb61021b 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -58,7 +58,7 @@ static double ImplGetParameter( const Point& rCenter, const Point& rPt, double f { const double nDX = static_cast(rPt.X()) - rCenter.X(); const double nDY = static_cast(rCenter.Y()) - rPt.Y(); - double fAngle = atan2(nDY, (nDX == 0) ? 0.000000001 : nDX); + double fAngle = atan2(nDY, nDX); return atan2(fWR*sin(fAngle), fHR*cos(fAngle)); }