Files
d3-spring-model/examples/js/src/example-papaparsing/neighbourSampling.js
Pitchaya Boonsarngsuk cf813a58c8 Neighbour change api
2018-02-05 16:44:01 +00:00

30 lines
825 B
JavaScript

/**
* Initialize the Chalmers' 1996 algorithm and start simulation.
*/
function startNeighbourSamplingSimulation() {
console.log("startNeighbourSamplingSimulation");
//springForce = true;
alreadyRanIterations = 0;
manualStop = true;
simulation.stop();
p1 = performance.now();
let force = d3.forceNeighbourSampling()
.neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE)
.distance(function (s, t) {
return distanceFunction(s, t, props, norm);
})
.stableVelocity(0.000001) //TODO
.onStableVelo(ended);
simulation
.alphaDecay(0)
.alpha(1)
.on("tick", ticked)
.on("end", ended)
.force(forceName, force);
// Restart the simulation.
simulation.restart();
}