]> granicus.if.org Git - graphviz/commitdiff
replace hypotenuse calculation in estimateError with a call to hypot
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 5 May 2021 03:43:45 +0000 (20:43 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 12 May 2021 01:46:36 +0000 (18:46 -0700)
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

index 990560f054a5acdbab4535629225dd20b05a4040..109a327e6dc1c55dbe35898b239ed5ce8df7e9d2 100644 (file)
@@ -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 {