Poisson Disk Sampling
初出 1986 · Robert L. Cook、Robert Bridson — Stochastic/Poisson-disk sampling — Cook (1986); fast algorithm, Bridson (2007). · 年表 ↗
コミュニティ・通称 名称 — 統計の Poisson(円板)過程にちなむ記述的用語。サンプリングの発想は Cook の 「stochastic sampling」(1986)、高速法は Bridson(2007)。人名エポニムではない。
ひとことで 互いに最小距離を保ちながら一様にランダムな点群を生成するサンプリング手法。Bridson の手法が高速。
コード
上のデモの実際のスケッチ(サンドボックスで再現可能)。これで全部です。
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);
}
}仕組み
Bridson の手法(2007)は最小距離 r を O(n) で達成する:セルサイズ r/√2 の背景グリッドを敷き(各セル最大 1 点で近傍判定が O(1))、ランダムな種点を 1 つ置いて active リストに入れる。active が空になるまで、ランダムな active 点の周囲の r〜2r のリングに最大 k 個の候補を試し、既存点すべてから r 以上離れた最初の候補を採用してグリッドと active に追加する。k 個すべて無効なら、その点を active から外す。これで隙間も塊もない一様な点群が得られる。
パラメータ
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).
系譜
よく組み合わされるアルゴリズム
- Perlin / Simplex Noise · 2 作品
- Circle Packing · 2 作品
- Fragment Shader (GLSL) · 2 作品
- Bezier / Catmull-Rom Splines · 2 作品
- Marching Squares / Contours · 1 作品
- Quadtree / Recursive Quad Split · 1 作品
- HSL / Hue Cycle · 1 作品
- Flow Field / Vector Field · 1 作品
- Raymarching with SDFs · 1 作品
- Voronoi Diagram · 1 作品
- Plotter-style Hatching · 1 作品
- Fractal / Recursive Subdivision · 1 作品
このアルゴリズムを使う作品 (6)
Ancient Courses of Fictional Rivers
robert-hodgin
Daisies
natthakit-susanthitanon-nsmag
Meridian
matt-deslauriers
Metropolis
mpkoz
Pieces of Me
r4v3n
Proscenium
remnynt
最終更新 2026-07-16