From d514ec5bc32402905b73660e551d2c3f6890ab3b Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk <2285135b@student.gla.ac.uk> Date: Wed, 24 Jan 2018 11:19:28 +0000 Subject: [PATCH] Fix Math mistake in stress calculation --- src/stress.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stress.js b/src/stress.js index de20514..40e42a5 100644 --- a/src/stress.js +++ b/src/stress.js @@ -12,8 +12,8 @@ export function getStress(nodes, distance) { let lowDDist = Math.hypot(target.x - source.x, target.y - source.y); let highDDist = distance(source, target); totalDiffSq += Math.pow(highDDist - lowDDist, 2); - totalHighDistSq += highDDist * highDDist; + totalLowDDistSq += lowDDist * lowDDist; } } - return Math.sqrt(totalDiffSq / totalHighDistSq); + return Math.sqrt(totalDiffSq / totalLowDDistSq); }