Skip to content

Instantly share code, notes, and snippets.

@tripzilch
tripzilch / quadtree.js
Last active December 5, 2023 21:59 — forked from L-A/quadtree.js
Basic quadtree implementation in JS
const CAPACITY = 8;
class QuadTree {
constructor(x, y, w, h) {
// the rect (x,y,w,h) defines the product of two half-open intervals: [x, x+w) × [y, y+h)
this.x = x; this.xe = x + w;
this.y = y; this.ye = y + h;
this.w = w;
this.h = h;
this.pts = [];