Delaunay Triangulation

初出 1934 · Boris Delaunay — Boris Delaunay (1934). · 年表 ↗

第三者・冠名 名称 — Boris Delaunay(1934) への後世の献名。Voronoi 図の双対で、Voronoi と同じ第三者エポニムの型。

ひとことで 点集合から三角形の集合を生成する方法。Voronoi の双対で、地形・ポリゴンアートの基礎となる。

Delaunay Triangulation · Open in new tab ↗ · Motion begins only when you press Run.

コード

上のデモの実際のスケッチ(サンドボックスで再現可能)。これで全部です。

delaunay/index.html
const SEED = Math.floor(Math.random()*1e9);

// Bowyer-Watson Delaunay triangulation of random points, drawn as a
// wireframe mesh with vertices marked.
function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  background('#0a0a0a');

  const N = 90;
  const pts = [];
  for (let i = 0; i < N; i++) pts.push({ x: random(s * 0.04, s * 0.96), y: random(s * 0.04, s * 0.96) });

  const tris = triangulate(pts, s);

  stroke(90, 200, 230, 150);
  strokeWeight(s * 0.0015);
  noFill();
  for (const t of tris) {
    triangle(t[0].x, t[0].y, t[1].x, t[1].y, t[2].x, t[2].y);
  }
  noStroke();
  fill('#7be0ff');
  for (const p of pts) circle(p.x, p.y, s * 0.006);
}

function circumcircle(a, b, c) {
  const ad = a.x*a.x + a.y*a.y, bd = b.x*b.x + b.y*b.y, cd = c.x*c.x + c.y*c.y;
  const D = 2 * (a.x*(b.y-c.y) + b.x*(c.y-a.y) + c.x*(a.y-b.y));
  if (Math.abs(D) < 1e-9) return null;
  const ux = (ad*(b.y-c.y) + bd*(c.y-a.y) + cd*(a.y-b.y)) / D;
  const uy = (ad*(c.x-b.x) + bd*(a.x-c.x) + cd*(b.x-a.x)) / D;
  const dx = a.x - ux, dy = a.y - uy;
  return { x: ux, y: uy, r2: dx*dx + dy*dy };
}

function triangulate(points, s) {
  // super-triangle
  const st = [{ x: -s*5, y: -s*5 }, { x: s*5, y: -s*5 }, { x: s/2, y: s*10 }];
  let tris = [[st[0], st[1], st[2]]];

  for (const p of points) {
    const bad = [];
    for (const t of tris) {
      const cc = circumcircle(t[0], t[1], t[2]);
      if (cc) {
        const dx = p.x - cc.x, dy = p.y - cc.y;
        if (dx*dx + dy*dy < cc.r2) bad.push(t);
      }
    }
    // boundary of the polygonal hole
    const edges = [];
    for (const t of bad) {
      const e = [[t[0], t[1]], [t[1], t[2]], [t[2], t[0]]];
      for (const ed of e) {
        const shared = bad.some((o) => o !== t && hasEdge(o, ed));
        if (!shared) edges.push(ed);
      }
    }
    tris = tris.filter((t) => !bad.includes(t));
    for (const ed of edges) tris.push([ed[0], ed[1], p]);
  }
  // drop triangles touching the super-triangle
  return tris.filter((t) => !t.some((v) => st.includes(v)));
}

function hasEdge(tri, ed) {
  const e = [[tri[0], tri[1]], [tri[1], tri[2]], [tri[2], tri[0]]];
  return e.some(([a, b]) => (a === ed[0] && b === ed[1]) || (a === ed[1] && b === ed[0]));
}

デモのソースを開く ↗

仕組み

定義は「空円(外接円)条件」— どの三角形の外接円の内部にも他の頂点が入らないとき Delaunay。代表的手法は、点を逐次追加し外接円内に入った三角形を消して空いた穴を再分割する増分法(Bowyer–Watson)、空円条件を破る共有辺を反転し続けるエッジフリップ、O(n log n) の分割統治/スイープライン。隣接三角形の外心を結ぶと双対のボロノイ図になる。

系譜

関連
Voronoi Diagram、3D Mesh / Geometry

よく組み合わされるアルゴリズム

このアルゴリズムを使う作品 (8)

Alien DNA
shvembldr
Cytographia
golan-levin
entretiempos
marcelo-soria-rodriguez
Gen 3
dca
glitch crystal monsters
alida-sun
Murano Fantasy
pandelune
Origami Dream
k0ch
Seadragons
marcin-ignac

最終更新 2026-07-16