Quad Tree
13 Oct 2020
A quadtree is a tree data structure in which each internal node has exactly four children.
Originally within databases for storing data in an easily searchable manner, it can also be used to find pixels in
a 2D plane. Here's a demonstration of just that.
In the canvas(right) below we have a bunch of points (colored Black) randomly scattered across. A quadtree is built in such a manner that each point is assigned at least one block of the quadtree. The quadtree's search functionality makes it easier to find the point closest (colored Red) to the mouse (colored Blue).
Quadtree searches are O(log n) searches as opposed to brute force searches that are O(n). There are two canvas below. The left one is a brute force search. The right one is QuadTree.
Javascript Demos ▼
Here's a bunch of javascript... things I wrote over the years whenever time permitted.
Abhivadaye Generator
Game of Life
Anagram Finder
Deflection Demo
Break Out
Cycloids
Double Pendulum
Flocking
Fog fly through
Fractals
EV Savings
Target Finder
Bouncing Spheres
Horizontal Stars
Image Scanning
Pandemic Simulator
JSON Beautify
Julia Sets
Kaleidoscope
Kock Fractals
Lorenz Attractor
Mandlebrot Set
Meta Balls
Number Convert
Number Game
Forces on Objects
Particles & Nodes
Simple Pendulum
Perlin Noise
Poisson Disk
QuadTree Search
8 Queens Problem
Natural Flocking
Ripples
Set Demonstration
Sine Waves
Classic Snake
Starfield
Sierpinski Triangles
Super Shapes 2D
Tic Tac Toe
Voronoi Diagram
Who Moved My...