A simple 2D ennetree (3×3 spatial division) for fast, efficient spatial queries.
An easy way to use this within a browser is to use the built-in DOMRect class, consider:
import { ennetree, type Bounds } from '@4bitlabs/ennetree';const rectBounds = (r: DOMRect) => [r.left, r.top, r.right, r.bottom];const space = ennetree<DOMRect>([0, 0, 1000, 1000], rectBounds);space.insert(new DOMRect(25, 25, 50, 50));const matches = space.search([20, 20, 80, 80]); Copy
import { ennetree, type Bounds } from '@4bitlabs/ennetree';const rectBounds = (r: DOMRect) => [r.left, r.top, r.right, r.bottom];const space = ennetree<DOMRect>([0, 0, 1000, 1000], rectBounds);space.insert(new DOMRect(25, 25, 50, 50));const matches = space.search([20, 20, 80, 80]);
ennetree
A simple 2D ennetree (3×3 spatial division) for fast, efficient spatial queries.
Example
An easy way to use this within a browser is to use the built-in DOMRect class, consider:
See
ennetree