From 58b30da1fadf51440d1772de4cccbd860d0ad64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 17 Oct 2024 17:08:31 +0200 Subject: [PATCH] Make use of `Math.hypot` --- src/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/link.js b/src/link.js index df6afa6..5fc5c73 100644 --- a/src/link.js +++ b/src/link.js @@ -35,7 +35,7 @@ export default function(links) { link = links[i], source = link.source, target = link.target; x = target.x + target.vx - source.x - source.vx || jiggle(random); y = target.y + target.vy - source.y - source.vy || jiggle(random); - l = Math.sqrt(x * x + y * y); + l = Math.hypot(x, y); l = (l - distances[i]) / l * alpha * strengths[i]; x *= l, y *= l; target.vx -= x * (b = bias[i]);