Tangent Arcs / String Art

First appeared 2021 · Dmitri Cherniak — The technique is old — external-tangent constructions between circles are classical geometry, and string art is a long-standing craft — so there is no single origin work. Its landmark generative-art instance is Dmitri Cherniak's "Ringers" (2021, Art Blocks), which parameterizes pegs, radii and wrap order into a taut looping line family. · timeline ↗

community / folk Name — A descriptive index label for a technique seen in Dmitri Cherniak's work (2021); not an established name, and no coiner is attested.

In one line A geometric method that strings tangent lines and arcs between pegs (circles) placed on a field, as if an elastic band or thread were wrapped around them — the technique behind Dmitri Cherniak's "Ringers".

Tangent Arcs / String Art · Open in new tab ↗ · Motion begins only when you press Run.

The code

The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.

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

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

  // 1. Place pegs on a grid (slight jitter), random radii.
  const N = 4 + Math.floor(random(3));
  const pad = s * 0.12;
  const cell = (s - pad * 2) / (N - 1);
  const pegs = [];
  for (let i = 0; i < N; i++) {
    for (let j = 0; j < N; j++) {
      if (random() < 0.55) continue;
      pegs.push({
        x: pad + i * cell + (random() - 0.5) * cell * 0.25,
        y: pad + j * cell + (random() - 0.5) * cell * 0.25,
        r: random(s * 0.015, s * 0.045),
      });
    }
  }
  if (pegs.length < 3) { window.location.reload(); return; }

  // 2. Choose a tour order (here: by atan2 around centroid → convex-ish wrap).
  const cx = pegs.reduce((a, p) => a + p.x, 0) / pegs.length;
  const cy = pegs.reduce((a, p) => a + p.y, 0) / pegs.length;
  pegs.sort((a, b) => Math.atan2(a.y - cy, a.x - cx) - Math.atan2(b.y - cy, b.x - cx));

  // 3. For each adjacent pair compute external tangent points and draw the
  //    string as straight segments + arcs around each peg.
  noFill();
  strokeWeight(s * 0.006);
  stroke('#222');

  const M = pegs.length;
  const tangents = [];
  for (let k = 0; k < M; k++) {
    const a = pegs[k];
    const b = pegs[(k + 1) % M];
    const [pa, pb] = externalTangent(a, b);
    tangents.push({ pa, pb });
  }
  for (let k = 0; k < M; k++) {
    const peg = pegs[(k + 1) % M];
    const t0 = tangents[k].pb;
    const t1 = tangents[(k + 1) % M].pa;
    // straight tangent segment
    line(tangents[k].pa.x, tangents[k].pa.y, tangents[k].pb.x, tangents[k].pb.y);
    // arc around peg connecting incoming → outgoing tangent.
    // p5.arc() draws from start→end clockwise; pick the shorter direction
    // by normalising to a0 ≤ a1 with delta ≤ π.
    let a0 = Math.atan2(t0.y - peg.y, t0.x - peg.x);
    let a1 = Math.atan2(t1.y - peg.y, t1.x - peg.x);
    while (a1 < a0) a1 += TWO_PI;
    if (a1 - a0 > Math.PI) {
      // shorter way is the other direction → flip
      const tmp = a0; a0 = a1 - TWO_PI; a1 = tmp;
    }
    arc(peg.x, peg.y, peg.r * 2, peg.r * 2, a0, a1);
  }

  // Draw pegs
  noStroke(); fill('#222');
  for (const p of pegs) circle(p.x, p.y, p.r * 0.4);
}

// External tangent on the right-hand side: returns the pair of points
// where the line is tangent to both circles (same-side tangent).
function externalTangent(a, b) {
  const dx = b.x - a.x;
  const dy = b.y - a.y;
  const d = Math.hypot(dx, dy);
  if (d <= Math.abs(a.r - b.r)) return [a, b]; // degenerate
  const cos = (a.r - b.r) / d;
  const sin = Math.sqrt(Math.max(0, 1 - cos*cos));
  // unit vector from a to b
  const ux = dx / d, uy = dy / d;
  // rotate (cos, sin) by direction
  const nx = ux * cos - uy * sin;
  const ny = ux * sin + uy * cos;
  return [
    { x: a.x + nx * a.r, y: a.y + ny * a.r },
    { x: b.x + nx * b.r, y: b.y + ny * b.r },
  ];
}

Open the demo source ↗

How it works

Place a set of pegs (circles of given radius) at positions in the plane. To "wrap a band" around them: 1. Order the pegs into a sequence (a path or hull-like loop). 2. Between each consecutive pair, draw the external tangent line segment that touches both circles on the same side — the straight part of the band. 3. At each peg, join the incoming and outgoing tangents with a circular arc along the peg's circumference, so the thread turns smoothly around it. Repeating with different peg orders, radii, wrap directions and start points yields the family of taut, looping line forms; randomising those parameters is exactly what generates each unique output.

Parameters

Lineage

Related
Bezier / Catmull-Rom Splines, Circle Packing

Frequently combined with

Works using this algorithm (3)

Antichambre
anaglyphic
Orbe
julien-gachadoat
Ringers
dmitri-cherniak

Last updated 2026-07-16