]> granicus.if.org Git - graphviz/commitdiff
replace hypotenuse calculation arrow_type_dot with a call to hypot
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 5 May 2021 03:39:43 +0000 (20:39 -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/arrows.c

index 7bc33c3a17e89d8cea6e711ff8e78cdedd197fb5..645df22dc8b679b709a2a4bcae58903ecfb375a0 100644 (file)
@@ -10,6 +10,7 @@
 
 
 #include <common/render.h>
+#include <math.h>
 
 #define EPSILON .0001
 
@@ -620,7 +621,7 @@ static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, double arrowsize, do
     double r;
     pointf AF[2];
 
-    r = sqrt(u.x * u.x + u.y * u.y) / 2.;
+    r = hypot(u.x, u.y) / 2.;
     AF[0].x = p.x + u.x / 2. - r;
     AF[0].y = p.y + u.y / 2. - r;
     AF[1].x = p.x + u.x / 2. + r;