Quadtree / Recursive Quad Split
初出 1974 · Raphael Finkel、Jon Bentley — Finkel & Bentley (1974). · 年表 ↗
発明者による命名 名称 · 命名 Raphael Finkel、Jon Bentley (1974) — 発明者による記述的命名。Finkel & Bentley の 1974 年論文が「quad trees」を用いた。
ひとことで 矩形を 4 分木的に再帰分割する空間データ構造、または絵画的にキャンバスを分割するレイアウト手法。
コード
上のデモの実際のスケッチ(サンドボックスで再現可能)。これで全部です。
quadtree/index.html
const SEED = Math.floor(Math.random()*1e9);
// Flat mid-century palette; each leaf cell picks one.
const PAL = [
[232, 74, 51], [244, 180, 26], [27, 153, 139],
[44, 95, 158], [241, 240, 230], [22, 28, 38],
];
function setup() {
randomSeed(SEED);
const s = Math.min(windowWidth, windowHeight);
createCanvas(s, s);
background(22, 28, 38);
stroke(10);
strokeWeight(Math.max(1, s / 400));
// Recursive quad split: each node either subdivides into four children
// or stops and paints itself. Past a minimum depth the split becomes a
// coin flip, so cell sizes vary across the canvas.
subdivide(0, 0, width, height, 0);
}
function subdivide(x, y, w, h, depth) {
const MAX = 7;
const minLeaf = width / 64;
const stop = depth >= MAX || w <= minLeaf || (depth >= 2 && random() < 0.5);
if (stop) {
const [r, g, b] = PAL[Math.floor(random(PAL.length))];
fill(r, g, b);
rect(x, y, w, h);
return;
}
const hw = w / 2, hh = h / 2;
subdivide(x, y, hw, hh, depth + 1);
subdivide(x + hw, y, hw, hh, depth + 1);
subdivide(x, y + hh, hw, hh, depth + 1);
subdivide(x + hw, y + hh, hw, hh, depth + 1);
}仕組み
領域全体を根ノードとし、再帰的に:(1) 分割基準を判定(点が k 個超、画像の色分散が閾値超、目標深さ未満 など)、(2) 分割すべきなら 4 等分して各象限へ再帰、そうでなければ葉にする。結果は詳細の高い所で細かく低い所で粗い木になる。構造としては範囲/最近接探索や衝突判定を高速化(O(log n))し、生成構図としては各葉を平均色で塗ると再帰矩形(モンドリアン/画像クアッドツリー)風、ランダムな分割判定で不規則な入れ子グリッドになる。
パラメータ
maxDepth: number — Maximum recursion depth of the subdivision.capacity: number — Points a node holds before it splits into four children.splitThreshold: number — Criterion (e.g. local density or variance) that triggers a split.
系譜
よく組み合わされるアルゴリズム
- Perlin / Simplex Noise · 7 作品
- HSL / Hue Cycle · 5 作品
- Boids / Flocking · 3 作品
- Fragment Shader (GLSL) · 3 作品
- Flow Field / Vector Field · 3 作品
- Bezier / Catmull-Rom Splines · 3 作品
- Marching Squares / Contours · 2 作品
- Voronoi Diagram · 2 作品
- Spring-Mass / Verlet · 2 作品
- Particle System · 2 作品
- Fractal / Recursive Subdivision · 2 作品
- Geometric / Hexagonal Tiling · 1 作品
このアルゴリズムを使う作品 (16)
Aerial View
dalenz
Ancient Courses of Fictional Rivers
robert-hodgin
Automatism
yazid
Cytographia
golan-levin
Democracity
generative-artworks
Fermented Fruit
cyberia
flora, fauna, false gods & floods
ryan-green
ilumz
wolffia-inc-motus-art
Interferences
juan-pedro-vallejo
Lacunae
james-dalessandro
Machine Comics
roni-block
pseudomods
erin-bee
Radiance
julien-gachadoat
SKEUOMORPHS
itsgalo
Twist
rafael-rozendaal
Window
jan-robert-leegte
最終更新 2026-07-16