This commit is contained in:
Pitchaya Boonsarngsuk
2018-02-06 13:32:31 +00:00
parent 4682c15a60
commit ff6abcd0f4
2 changed files with 3 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ export default function() {
nodes,
stableVelocity = 0,
stableVeloHandler = null,
latestVelocityDiff = 0
latestVelocityDiff = 0,
iterations = 1;
function force(alpha) {
@@ -95,7 +95,7 @@ export default function() {
force.latestAccel = function () {
return latestVelocityDiff;
};
force.onStableVelo = function (_) {
return arguments.length ? (stableVeloHandler = _, force) : stableVeloHandler;
};

View File

@@ -7,7 +7,7 @@
export function getStress(nodes, distance) {
let sumDiffSq = 0
let sumLowDDistSq = 0;
for (let j = nodes.length-1; j >= 1; j++) {
for (let j = nodes.length-1; j >= 1; j--) {
for (let i = 0; i < j; i++) {
let source = nodes[i], target = nodes[j];
let lowDDist = Math.hypot(target.x - source.x, target.y - source.y);