Poisson Disk Sampling
First appeared 1986 · Robert L. Cook, Robert Bridson — Stochastic/Poisson-disk sampling — Cook (1986); fast algorithm, Bridson (2007). · timeline ↗
community / folk Name — Descriptive term referencing the statistical Poisson (disk) process; the sampling idea is Cook's "stochastic sampling" (1986), with Bridson's fast algorithm (2007). Not a personal eponym.
In one line A sampling method that scatters points uniformly at random while keeping every pair at least a minimum distance apart — "blue-noise" distribution with no clumps or gaps. Bridson's algorithm makes it fast.
The code
The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.
poisson-disk/index.html
const SEED = Math.floor(Math.random()*1e9);
// Bridson's fast Poisson-disk sampling: points kept at least r apart, via a
// background grid + active list. Points coloured by distance from centre.
function setup() {
randomSeed(SEED);
const s = Math.min(windowWidth, windowHeight);
createCanvas(s, s);
background('#f5f1e8');
colorMode(HSB, 360, 100, 100);
noStroke();
const r = s * 0.028;
const k = 30;
const cell = r / Math.SQRT2;
const cols = Math.ceil(s / cell), rows = Math.ceil(s / cell);
const grid = new Array(cols * rows).fill(null);
const active = [];
const pts = [];
const add = (p) => {
pts.push(p);
active.push(p);
grid[Math.floor(p.x/cell) + Math.floor(p.y/cell)*cols] = p;
};
add({ x: s/2, y: s/2 });
while (active.length) {
const idx = Math.floor(random(active.length));
const p = active[idx];
let placed = false;
for (let i = 0; i < k; i++) {
const a = random(TWO_PI), m = random(r, 2*r);
const np = { x: p.x + Math.cos(a)*m, y: p.y + Math.sin(a)*m };
if (np.x < 0 || np.y < 0 || np.x >= s || np.y >= s) continue;
const gx = Math.floor(np.x/cell), gy = Math.floor(np.y/cell);
let ok = true;
for (let yy = -2; yy <= 2 && ok; yy++)
for (let xx = -2; xx <= 2; xx++) {
const nx = gx+xx, ny = gy+yy;
if (nx<0||ny<0||nx>=cols||ny>=rows) continue;
const q = grid[nx + ny*cols];
if (q) { const dx=q.x-np.x, dy=q.y-np.y; if (dx*dx+dy*dy < r*r) { ok=false; break; } }
}
if (ok) { add(np); placed = true; break; }
}
if (!placed) active.splice(idx, 1);
}
const baseHue = random(360);
for (const p of pts) {
const d = Math.hypot(p.x - s/2, p.y - s/2) / (s*0.7);
fill((baseHue + d*120) % 360, 70, 90);
circle(p.x, p.y, r * 0.62);
}
}How it works
Bridson's algorithm (2007) targets a minimum distance r in O(n): 1. Overlay a background grid with cell size r/√2, so each cell holds at most one sample — making neighbour checks O(1). 2. Seed one random point; add it to the grid and to an "active" list. 3. While the active list is non-empty, pick a random active point and try up to k candidates in the annulus between r and 2r around it. Accept the first candidate that is ≥ r from all existing samples (checked via nearby grid cells); add it to the grid and active list. 4. If none of the k candidates is valid, remove the point from the active list. Repeat until empty. The result is an even, gap-and-clump-free random point set.
Parameters
minDistance: number — Minimum spacing enforced between any two samples (the disk radius r).k: number — Candidate attempts per active sample before it is rejected (Bridson’s k, commonly 30).
Lineage
Frequently combined with
- Perlin / Simplex Noise · 2 works
- Circle Packing · 2 works
- Fragment Shader (GLSL) · 2 works
- Bezier / Catmull-Rom Splines · 2 works
- Marching Squares / Contours · 1 work
- Quadtree / Recursive Quad Split · 1 work
- HSL / Hue Cycle · 1 work
- Flow Field / Vector Field · 1 work
- Raymarching with SDFs · 1 work
- Voronoi Diagram · 1 work
- Plotter-style Hatching · 1 work
- Fractal / Recursive Subdivision · 1 work
Works using this algorithm (6)
Last updated 2026-07-16