From 96ceb61588e3e267032fd349a9ee86f60583c6cc Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 17 Jun 2021 18:19:29 -0700 Subject: [PATCH] replace some open coded hypotenuse calculations in applyAttr with calls to hypot Similar to the previous commits. --- lib/fdpgen/xlayout.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); -- 2.40.0