Fix Math mistake in stress calculation

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-24 11:19:28 +00:00
parent 37d2f5b021
commit d514ec5bc3

View File

@@ -12,8 +12,8 @@ export function getStress(nodes, distance) {
let lowDDist = Math.hypot(target.x - source.x, target.y - source.y); let lowDDist = Math.hypot(target.x - source.x, target.y - source.y);
let highDDist = distance(source, target); let highDDist = distance(source, target);
totalDiffSq += Math.pow(highDDist - lowDDist, 2); totalDiffSq += Math.pow(highDDist - lowDDist, 2);
totalHighDistSq += highDDist * highDDist; totalLowDDistSq += lowDDist * lowDDist;
} }
} }
return Math.sqrt(totalDiffSq / totalHighDistSq); return Math.sqrt(totalDiffSq / totalLowDDistSq);
} }