Functional Quadtrees
created: Dec. 4, 2025, 1:18 p.m. | updated: Dec. 4, 2025, 11:39 p.m.
A Quadtree is a tree data structure, which is useful for giving more focus/detail to certain regions of your data, while saving resources elsewhere.
A demoIn this blogpost I'll show you how to build both a functional Quadtree and the visualization you see below.
Determines if the camera is closer than halfway to the edge of a node " [ node camera ] (< (distance camera (:center node)) (:width node))) (defn split?
node camera) (> (:width node) _Q_MINIMUM_SIZE)))That final check on the width of the node, essentially allow us to recurse until we can't split anymore.
tree) tree (get-tree-color tree)) (when-let [children (:children tree)] (doseq [c children] (draw-all c))))However there's a fun detail here.
6 days, 10 hours ago: Hacker News