แก้ coding style

This commit is contained in:
Pitchaya Boonsarngsuk
2018-03-22 16:02:45 +00:00
parent b601af68b4
commit 2256af7448
9 changed files with 866 additions and 873 deletions

View File

@@ -52,10 +52,7 @@ export default function() {
quad.data = children[Math.floor(Math.random() * children.length)]; quad.data = children[Math.floor(Math.random() * children.length)];
quad.x = quad.data.x; quad.x = quad.data.x;
quad.y = quad.data.y; quad.y = quad.data.y;
} } else { // For leaf nodes, accumulate forces from coincident quadrants.
// For leaf nodes, accumulate forces from coincident quadrants.
else {
q = quad; q = quad;
q.x = q.data.x; q.x = q.data.x;
q.y = q.data.y; q.y = q.data.y;
@@ -93,10 +90,7 @@ export default function() {
node.vy += y; node.vy += y;
} }
return true; return true;
} } else if (quad.length) return; // Otherwise, process points directly.
// Otherwise, process points directly.
else if (quad.length) return;
// Limit forces for very close nodes; randomize direction if coincident. // Limit forces for very close nodes; randomize direction if coincident.
if (quad.data !== node || quad.next) { if (quad.data !== node || quad.next) {

View File

@@ -40,8 +40,7 @@ export function takeSampleFrom(sourceList, amount) {
sample: remainder, sample: remainder,
remainder: randElements remainder: randElements
}; };
} } else {
else {
return { return {
sample: randElements, sample: randElements,
remainder: remainder remainder: remainder

View File

@@ -55,15 +55,13 @@ export function placeNearToNearestNeighbour(node, nearNeighbour, radius, sampleS
lowBound = 90; lowBound = 90;
highBound = 180; highBound = 180;
} }
} else { } else if (dist90 > dist270) {
if (dist90 > dist270) {
lowBound = 270; lowBound = 270;
highBound = 360; highBound = 360;
} else { } else {
lowBound = 0; lowBound = 0;
highBound = 90; highBound = 90;
} }
}
// Determine the angle // Determine the angle
let angle = binarySearchMin(lowBound, highBound, sumDistErrorByAngle); let angle = binarySearchMin(lowBound, highBound, sumDistErrorByAngle);

View File

@@ -53,7 +53,9 @@ export default function() {
let u = 2 * Math.random() - 1; let u = 2 * Math.random() - 1;
let v = 2 * Math.random() - 1; let v = 2 * Math.random() - 1;
let r = u * u + v * v; let r = u * u + v * v;
if (r == 0 || r > 1) {return gaussRandom();} if (r == 0 || r > 1) {
return gaussRandom();
}
return u * Math.sqrt(-2 * Math.log(r) / r); return u * Math.sqrt(-2 * Math.log(r) / r);
} }