From f0a9fd9d4d874aa99964c7a63995c5f37c098d1b Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 4 May 2021 20:43:45 -0700 Subject: [PATCH] replace hypotenuse calculation in estimateError with a call to hypot The function hypot is available in C99 and has the potential to compute the same operation more efficiently and with greater precision. --- lib/common/ellipse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/common/ellipse.c b/lib/common/ellipse.c index 990560f05..109a327e6 100644 --- a/lib/common/ellipse.c +++ b/lib/common/ellipse.c @@ -362,8 +362,7 @@ estimateError(ellipse_t * ep, int degree, double etaA, double etaB) double dx = xB - xA; double dy = yB - yA; - return fabs(x * dy - y * dx + xB * yA - xA * yB) - / sqrt(dx * dx + dy * dy); + return fabs(x * dy - y * dx + xB * yA - xA * yB) / hypot(dx, dy); } else { -- 2.40.0