Remove multiplier from neighbour sampling

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-15 11:21:47 +00:00
parent 3a93c843c9
commit c11c902e69
3 changed files with 7 additions and 16 deletions

View File

@@ -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);

View File

@@ -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;
};