Skip to content

Commit fb552bd

Browse files
author
Chris Hallberg
committed
Add a few clarifying comments.
1 parent d4cfe34 commit fb552bd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

quadtree.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ class QuadTree {
297297
}
298298

299299
if (typeof maxDistance === "undefined") {
300-
// A circle that contains the entire QuadTree
300+
// A circle as big as the QuadTree's boundary
301301
const outerReach = Math.sqrt(
302302
Math.pow(this.boundary.w, 2) + Math.pow(this.boundary.h, 2)
303303
);
304304
// Distance of query point from center
305305
const pointDistance = Math.sqrt(
306306
Math.pow(point.x, 2) + Math.pow(point.y, 2)
307307
);
308-
// One QuadTree size away from the query point
308+
// Together, a circle that encompasses the whole QuadTree
309309
maxDistance = outerReach + pointDistance;
310310
}
311311

@@ -321,8 +321,10 @@ class QuadTree {
321321
if (points.length === count) {
322322
return points; // Return when we hit the right size
323323
} else if (points.length < count) {
324+
// Grow
324325
inner = radius;
325326
} else {
327+
// Shrink
326328
outer = radius;
327329
limit --;
328330
}

0 commit comments

Comments
 (0)