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