Visualizations
330 / 500

330 · Math

Kakeya Needle

Turn a needle all the way around in a disk, a deltoid, then sprouting Perron trees.

Kakeya asked in 1917 for the smallest region in which a unit needle can be turned through 180 degrees. A disk needs pi/4, a three-point turn in a triangle 1/sqrt(3), and the deltoid pi/8, with the needle always tangent. Besicovitch showed there is no minimum, and this demo builds his sets: each corner fan of the triangle is cut into 2^n thin triangles that are slid together level by level (the Perron tree construction), and the union's area is measured live with scanlines. The needle pivots inside each sliver and hops between them with Pál joins, sliding about 200 needle lengths out along its own line so the hop costs almost no area. The trees beat the triangle at n = 5 and the deltoid at n = 8, and the area keeps falling, slowly, toward zero.

Try it. Click a construction in the panel (or press 1 to 4) to watch the needle turn in it. Drag the n slider or use the arrow keys to sprout more triangles and see the area meter and chart respond. Space pauses, R restarts the turn.

  • Perron tree construction
  • Pál joins
  • Scanline union area
  • Engraving-style line art

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build an animated illustration of the Kakeya needle problem with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

The problem: what is the smallest area in which a needle of length 1 can be turned all the way around (through 180 degrees)?

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens, and maps world coordinates (units of the needle length, y up) to the screen.
- Show three solutions one after another. A disk of diameter 1: spin the needle about its center. An equilateral triangle of height 1: pivot 60 degrees about a corner, slide along a side to the next corner, and repeat three times. The deltoid z(t) = r (2e^(it) + e^(-2it)) with r = 1/4: the needle's ends are z(s) and z(s + pi), and as s goes from 0 to pi the needle turns all the way around while staying tangent.
- Animate the needle as a list of motion segments (rotate about a point, or slide along a vector) played back in order.
- Show each shape's area beside it: pi/4, 1/sqrt(3) and pi/8.

Once that works, make it beautiful:
- Give it the look of an old engraving: cream paper, sepia ink, shapes filled with fine hatching clipped to their outline, and a steel needle with an eye at one end.
- Leave a fading trail of the needle's recent positions so you can see the region it sweeps.
- Draw an area meter with a bar for each shape.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as Perron trees that cut the triangle into 2^n slivers and slide them together to shrink the area, Pál joins that move the needle between parallel lines at almost no cost, or measuring the union's area with scanlines.
PreviousColor ConstancyStrawberries under cyan light: not a single red pixel, and they still look red. NextPigment MixingBlue and yellow paint make green here: spectral Kubelka-Munk mixing beside naive RGB.

Related visualizations

  • Triangle CentersMath Drag a triangle: 46 Kimberling centers, the Euler line and Morley's triangle follow.
  • Penrose PentagridMath Five grids of parallel lines dualize into a living Penrose tiling of stained glass.
  • KnittingType and image Pixel art becomes Fair Isle knitting, stitch by twisted stitch, live on the needle.
  • Catalan BijectionsMath One Catalan object drawn five ways at once, linked piece by piece as it morphs.
  • Apollonian GasketFractals An endless packing of kissing circles, each engraved with its exact integer curvature.
  • Wythoff Kaleidoscope3D One draggable seed in a mirror triangle generates every convex uniform polyhedron.
  • Hyperbolic TilingMath An endless koi garden of {p,q} ponds tiling the Poincare disk, with fish circling.
  • Arnold's Cat MapMath A painted cat is sheared into noise, then reassembles itself exactly on schedule.
  • Ford CirclesMath A circle for every fraction, and a dive into why the golden ratio is the most irrational.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs