]> granicus.if.org Git - graphviz/commitdiff
replace some open coded hypotenuse calculations in applyAttr with calls to hypot
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 18 Jun 2021 01:19:29 +0000 (18:19 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Jun 2021 20:28:10 +0000 (13:28 -0700)
Similar to the previous commits.

lib/fdpgen/xlayout.c

index fe784a7666c55d4a4af51734dcc83a85d2ac23af..adb301f7c3b6c238c05e3cd832f320f6865df09e 100644 (file)
@@ -338,12 +338,12 @@ static void applyAttr(Agnode_t * p, Agnode_t * q)
        return;
     xdelta = ND_pos(q)[0] - ND_pos(p)[0];
     ydelta = ND_pos(q)[1] - ND_pos(p)[1];
-    dist = sqrt(xdelta * xdelta + ydelta * ydelta);
+    dist = hypot(xdelta, ydelta);
     force = (dout * dout) / (X_K * dist);
 #elif defined(ALT)
     xdelta = ND_pos(q)[0] - ND_pos(p)[0];
     ydelta = ND_pos(q)[1] - ND_pos(p)[1];
-    dist = sqrt(xdelta * xdelta + ydelta * ydelta);
+    dist = hypot(xdelta, ydelta);
     din = RAD(p) + RAD(q);
     if (dist < X_K + din)
        return;
@@ -361,7 +361,7 @@ static void applyAttr(Agnode_t * p, Agnode_t * q)
     }
     xdelta = ND_pos(q)[0] - ND_pos(p)[0];
     ydelta = ND_pos(q)[1] - ND_pos(p)[1];
-    dist = sqrt(xdelta * xdelta + ydelta * ydelta);
+    dist = hypot(xdelta, ydelta);
     din = RAD(p) + RAD(q);
     dout = dist - din;
     force = dout * dout / ((X_K + din) * dist);