Strange Attractor

初出 1963 · Edward Lorenz — Edward Lorenz (1963); Clifford/De Jong attractors later popularized in art. · 年表 ↗

第三者・冠名 名称 (1971) — 二トラックの分離。現象は Lorenz(1963) に遡るが、「strange attractor」という名は David Ruelle と Floris Takens が「On the Nature of Turbulence」(1971) で命名した—— 命名者は発見者ではない。

ひとことで Lorenz / Clifford / Pickover 等のカオス力学系。少数の方程式から複雑な軌跡が描かれる。

Strange Attractor · Open in new tab ↗ · Motion begins only when you press Run.

コード

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

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

// Clifford attractor:  x' = sin(a·y) + c·cos(a·x), y' = sin(b·x) + d·cos(b·y)
// Random (a,b,c,d) often degenerate — use a curated list of known-attractive
// parameter sets (the visual is always non-trivial).
const PARAMS = [
  [-1.4,  1.6,  1.0,  0.7],
  [-1.7,  1.3, -0.1, -1.21],
  [ 1.5, -1.8,  1.6,  0.9],
  [-1.8, -2.0, -0.5, -0.9],
  [-1.7,  1.8, -1.9, -0.4],
  [ 1.6, -0.6, -1.2,  1.6],
  [-2.0, -2.0, -1.2,  2.0],
  [-1.24, -1.25, -1.81, -1.91],
  [ 1.7,  1.7,  0.6,  1.2],
  [-1.7,  1.8, -0.9, -0.4],
];

function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  background('#0a0a0a');
  noStroke();

  const [A, B, C, D] = PARAMS[Math.floor(random(PARAMS.length))];

  // Iterate to compute bounds (warm-up + bounding box).
  let x = 0.1, y = 0.1;
  for (let i = 0; i < 1000; i++) {
    const nx = Math.sin(A * y) + C * Math.cos(A * x);
    const ny = Math.sin(B * x) + D * Math.cos(B * y);
    x = nx; y = ny;
  }
  let xmin = Infinity, xmax = -Infinity, ymin = Infinity, ymax = -Infinity;
  for (let i = 0; i < 20000; i++) {
    const nx = Math.sin(A * y) + C * Math.cos(A * x);
    const ny = Math.sin(B * x) + D * Math.cos(B * y);
    x = nx; y = ny;
    if (x < xmin) xmin = x;
    if (x > xmax) xmax = x;
    if (y < ymin) ymin = y;
    if (y > ymax) ymax = y;
  }
  const xspan = xmax - xmin || 1;
  const yspan = ymax - ymin || 1;
  const span = Math.max(xspan, yspan) * 1.05;
  const offsetX = (xmin + xmax) / 2;
  const offsetY = (ymin + ymax) / 2;

  // Density buffer keyed by canvas-space pixel.
  const N = 280000;
  const density = new Float32Array(width * height);
  let maxD = 0;
  x = 0.1; y = 0.1;
  for (let i = 0; i < 1000; i++) {
    const nx = Math.sin(A * y) + C * Math.cos(A * x);
    const ny = Math.sin(B * x) + D * Math.cos(B * y);
    x = nx; y = ny;
  }
  for (let i = 0; i < N; i++) {
    const nx = Math.sin(A * y) + C * Math.cos(A * x);
    const ny = Math.sin(B * x) + D * Math.cos(B * y);
    x = nx; y = ny;
    const px = Math.floor(((x - offsetX) / span + 0.5) * width);
    const py = Math.floor(((y - offsetY) / span + 0.5) * height);
    if (px >= 0 && py >= 0 && px < width && py < height) {
      const idx = py * width + px;
      density[idx] += 1;
      if (density[idx] > maxD) maxD = density[idx];
    }
  }

  pixelDensity(1);
  loadPixels();
  const logMax = Math.log(1 + maxD);
  for (let i = 0; i < density.length; i++) {
    if (density[i] === 0) continue;
    const t = Math.log(1 + density[i]) / logMax;
    // magma-ish ramp: black → purple → red → orange → yellow
    const r = Math.round(255 * Math.min(1, t * 1.6 - 0.1));
    const g = Math.round(255 * Math.max(0, t * t * 1.4 - 0.3));
    const bl = Math.round(255 * Math.max(0, 0.5 * t - Math.max(0, t - 0.5)));
    const idx = i * 4;
    pixels[idx]     = r;
    pixels[idx + 1] = g;
    pixels[idx + 2] = bl;
    pixels[idx + 3] = 255;
  }
  updatePixels();
}

デモのソースを開く ↗

仕組み

点と少数の更新式・固定パラメータを用意する(例:De Jong 写像 xₙ₊₁=sin(a·yₙ)−cos(b·xₙ)、yₙ₊₁=sin(c·xₙ)−cos(d·yₙ))。(1) 種点から始め、(2) 式を反復して次点を求める(数百万ステップ)、(3) 各点を描画(または密度を蓄積)し、最初の数百回はアトラクタに収束させるため捨てる。系は決定論的だが初期値鋭敏性(カオス)を持ち、軌道は精緻な自己相似形を埋める。密度蓄積+トーンマッピングで微細なフィラメントが現れ、a,b,c,d が「ゲノム」になる。

パラメータ

系譜

関連
Physics Simulation

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

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

Attraction
jos-vromans
Augmented Sequence
toiminto
Edifice
ben-kovach
Gravity 16
jimmy-herdberg
Hashtractors
darien-brito
Human Unreadable
operator

最終更新 2026-07-16