From: Matthew Fernandez Date: Fri, 18 Jun 2021 01:19:29 +0000 (-0700) Subject: replace some open coded hypotenuse calculations in applyAttr with calls to hypot X-Git-Tag: 2.48.0~43^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96ceb61588e3e267032fd349a9ee86f60583c6cc;p=graphviz replace some open coded hypotenuse calculations in applyAttr with calls to hypot Similar to the previous commits. --- diff --git a/lib/fdpgen/xlayout.c b/lib/fdpgen/xlayout.c index fe784a766..adb301f7c 100644 --- a/lib/fdpgen/xlayout.c +++ b/lib/fdpgen/xlayout.c @@ -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);