Remove multiplier from neighbour sampling
This commit is contained in:
@@ -264,12 +264,11 @@ function startNeighbourSamplingSimulation() {
|
||||
.neighbourSize(NEIGHBOUR_SIZE)
|
||||
.sampleSize(SAMPLE_SIZE)
|
||||
// .freeness(0.5)
|
||||
.multiplier(MULTIPLIER)
|
||||
.distanceRange(SELECTED_DISTANCE)
|
||||
// The distance function that will be used to calculate distances
|
||||
// between nodes.
|
||||
.distance(function (s, t) {
|
||||
return distanceFunction(s, t, props, norm);
|
||||
return distanceFunction(s, t, props, norm) * MULTIPLIER;
|
||||
}));
|
||||
// Restart the simulation.
|
||||
console.log(simulation.force(forceName).neighbourSize(), simulation.force(forceName).sampleSize());
|
||||
|
||||
@@ -16,8 +16,7 @@ export default function (nodes, config) {
|
||||
FullneighbourSize = config.hasOwnProperty("fullNeighbourSize") ? config.fullNeighbourSize : 6,
|
||||
FullsampleSize = config.hasOwnProperty("fullSampleSize") ? config.fullSampleSize : 3,
|
||||
FulldistanceRange = config.hasOwnProperty("fullDistanceRange") ? config.fullDistanceRange : 10,
|
||||
MULTIPLIER = config.hasOwnProperty("multiplier") ? config.multiplier : 50,
|
||||
distance = config.hasOwnProperty("distance") ? config.distance : constant(300),
|
||||
distanceFn = config.hasOwnProperty("distanceFn") ? config.distance : constant(300),
|
||||
PIVOTS = config.hasOwnProperty("pivots") ? config.pivots : false,
|
||||
NUMPIVOTS = config.hasOwnProperty("numPivots") ? config.numPivots : 3,
|
||||
event = d3.dispatch("sampleTick", "fullTick", "startFull", "end");
|
||||
@@ -40,8 +39,7 @@ export default function (nodes, config) {
|
||||
.neighbourSize(neighbourSize)
|
||||
.sampleSize(sampleSize)
|
||||
.distanceRange(distanceRange)
|
||||
.distance(distance)
|
||||
.multiplier(MULTIPLIER)
|
||||
.distance(distanceFn)
|
||||
)
|
||||
.alpha(1).restart();
|
||||
|
||||
@@ -66,8 +64,7 @@ export default function (nodes, config) {
|
||||
.neighbourSize(FullneighbourSize)
|
||||
.sampleSize(FullsampleSize)
|
||||
.distanceRange(FulldistanceRange)
|
||||
.distance(distance)
|
||||
.multiplier(MULTIPLIER)
|
||||
.distance(distanceFn)
|
||||
)
|
||||
.on("tick", function () {
|
||||
event.call("fullTick", fullSimulation);
|
||||
|
||||
@@ -29,8 +29,7 @@ export default function () {
|
||||
//freeness = 0.85,
|
||||
//springForce = 0.7,
|
||||
//dampingFactor = 0.3,
|
||||
velocity,
|
||||
multiplier = 50;
|
||||
velocity;
|
||||
|
||||
/**
|
||||
* Calculates the forces at each iteration between the node and the
|
||||
@@ -72,7 +71,7 @@ export default function () {
|
||||
x = target.x + target.vx - source.x - source.vx || jiggle();
|
||||
y = target.y + target.vy - source.y - source.vy || jiggle();
|
||||
l = Math.sqrt(x * x + y * y);
|
||||
l = (l - dist * multiplier) / l * alpha;
|
||||
l = (l - dist) / l * alpha;
|
||||
x *= l, y *= l;
|
||||
velocity += x + y;
|
||||
// Set the calculated velocites for both nodes.
|
||||
@@ -219,7 +218,7 @@ export default function () {
|
||||
if (i !== j) {
|
||||
source = nodes[i], target = nodes[j];
|
||||
realDist = Math.hypot(target.x - source.x, target.y - source.y);
|
||||
highDist = +distance(source, target) * multiplier;
|
||||
highDist = +distance(source, target);
|
||||
totalDiffSq += Math.pow(realDist - highDist, 2);
|
||||
totalHighDistSq += highDist * highDist;
|
||||
}
|
||||
@@ -285,10 +284,6 @@ export default function () {
|
||||
return arguments.length ? (distanceRange = +_, force) : distanceRange;
|
||||
};
|
||||
|
||||
force.multiplier = function (_) {
|
||||
return arguments.length ? (multiplier = +_, initialize(), force) : multiplier;
|
||||
};
|
||||
|
||||
force.nodeNeighbours = function (_) {
|
||||
return arguments.length ? neighbours[+_] : neighbours;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user