แก้ coding style ภาค 7
This commit is contained in:
@@ -28,7 +28,7 @@ export default function () {
|
||||
function force (_) {
|
||||
var i, n = nodes.length, tree = quadtree(nodes, x, y).visitAfter(accumulate);
|
||||
for (alpha = _, i = 0; i < n; ++i) {
|
||||
node = nodes[i], tree.visit(apply);
|
||||
node = nodes[i]; tree.visit(apply);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ export default function () {
|
||||
// Apply the Barnes-Hut approximation if possible.
|
||||
// Limit forces for very close nodes; randomize direction if coincident.
|
||||
if (w / l < theta) {
|
||||
if (x === 0) x = jiggle(), l += x * x;
|
||||
if (y === 0) y = jiggle(), l += y * y;
|
||||
if (x === 0) {x = jiggle(); l += x * x;}
|
||||
if (y === 0) {y = jiggle(); l += y * y;}
|
||||
if (quad.data) {
|
||||
l = (l - +distance(node, quad.data)) / l * alpha;
|
||||
x *= l, y *= l;
|
||||
@@ -93,14 +93,14 @@ export default function () {
|
||||
|
||||
// Limit forces for very close nodes; randomize direction if coincident.
|
||||
if (quad.data !== node || quad.next) {
|
||||
if (x === 0) x = jiggle(), l += x * x;
|
||||
if (y === 0) y = jiggle(), l += y * y;
|
||||
if (x === 0) {x = jiggle(); l += x * x;}
|
||||
if (y === 0) {y = jiggle(); l += y * y;}
|
||||
}
|
||||
|
||||
do {
|
||||
if (quad.data !== node) {
|
||||
l = (l - +distance(node, quad.data)) / l * alpha;
|
||||
x *= l, y *= l;
|
||||
x *= l; y *= l;
|
||||
quad.data.vx -= x;
|
||||
quad.data.vy -= y;
|
||||
node.vx += x;
|
||||
@@ -120,7 +120,7 @@ export default function () {
|
||||
for (var i = 0, source, target, realDist, highDist; i < nodes.length; i++) {
|
||||
for (var j = 0; j < nodes.length; 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);
|
||||
highDist = +distance(nodes[i], nodes[j]);
|
||||
totalDiffSq += Math.pow(realDist - highDist, 2);
|
||||
|
||||
@@ -42,8 +42,8 @@ export default function (sim, forceS, forceF) {
|
||||
alreadyRanIterations,
|
||||
hybrid;
|
||||
|
||||
if (simulation != undefined) initSimulation();
|
||||
if (forceS != undefined || forceF != undefined) initForces();
|
||||
if (simulation !== undefined) initSimulation();
|
||||
if (forceS !== undefined || forceF !== undefined) initForces();
|
||||
|
||||
// Performed on first run
|
||||
function initialize () {
|
||||
@@ -68,7 +68,7 @@ export default function (sim, forceS, forceF) {
|
||||
|
||||
// Set default value for interpDistanceFn if not been specified yet
|
||||
if (interpDistanceFn === undefined) {
|
||||
if (forceFull.distance == 'function') {
|
||||
if (forceFull.distance === 'function') {
|
||||
interpDistanceFn = forceFull.distance();
|
||||
} else {
|
||||
interpDistanceFn = constant(300);
|
||||
|
||||
@@ -37,9 +37,9 @@ export function placeNearToNearestNeighbour (node, nearNeighbour, radius, sample
|
||||
highBound = 0.0;
|
||||
|
||||
// Determine the closest quadrant
|
||||
if (dist0 == dist180) {
|
||||
if (dist0 === dist180) {
|
||||
if (dist90 > dist270) { lowBound = highBound = 270; } else { lowBound = highBound = 90; }
|
||||
} else if (dist90 == dist270) {
|
||||
} else if (dist90 === dist270) {
|
||||
if (dist0 > dist180) { lowBound = highBound = 180; } else { lowBound = highBound = 0; }
|
||||
} else if (dist0 > dist180) {
|
||||
if (dist90 > dist270) {
|
||||
@@ -87,7 +87,7 @@ function sumForcesToSample (node, samples, sampleCache) {
|
||||
y = node.y - sample.y || jiggle();
|
||||
l = Math.sqrt(x * x + y * y);
|
||||
l = (l - sampleCache[i]) / l;
|
||||
x *= l, y *= l;
|
||||
x *= l; y *= l;
|
||||
nodeVx -= x;
|
||||
nodeVy -= y;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ function binarySearchMin (lb, hb, fn) {
|
||||
while (lb <= hb) {
|
||||
if (lb === hb) return lb;
|
||||
|
||||
if (hb - lb == 1) {
|
||||
if (hb - lb === 1) {
|
||||
if (fn(lb) >= fn(hb)) return hb;
|
||||
else return lb;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export default function () {
|
||||
y = target.y + target.vy - source.y - source.vy || jiggle();
|
||||
l = Math.sqrt(x * x + y * y);
|
||||
l = (l - dist) / l * dataSizeFactor * alpha;
|
||||
x *= l, y *= l;
|
||||
x *= l; y *= l;
|
||||
// Set the calculated velocites for both nodes.
|
||||
target.vx -= x;
|
||||
target.vy -= y;
|
||||
|
||||
@@ -53,7 +53,7 @@ export default function () {
|
||||
let u = 2 * Math.random() - 1;
|
||||
let v = 2 * Math.random() - 1;
|
||||
let r = u * u + v * v;
|
||||
if (r == 0 || r > 1) {
|
||||
if (r === 0 || r > 1) {
|
||||
return gaussRandom();
|
||||
}
|
||||
return u * Math.sqrt(-2 * Math.log(r) / r);
|
||||
@@ -140,7 +140,7 @@ export default function () {
|
||||
// Normalize p and compute entropy.
|
||||
var Hhere = 0.0;
|
||||
for (j = 0; j < N; j++) {
|
||||
if (psum == 0) {
|
||||
if (psum === 0) {
|
||||
pj = 0;
|
||||
} else {
|
||||
pj = prow[j] / psum;
|
||||
@@ -329,7 +329,7 @@ export default function () {
|
||||
for (var i = 0, source, target, realDist, highDist; i < nodes.length; i++) {
|
||||
for (var j = 0; j < nodes.length; 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);
|
||||
highDist = +distance(nodes[i], nodes[j]);
|
||||
totalDiffSq += Math.pow(realDist - highDist, 2);
|
||||
|
||||
Reference in New Issue
Block a user