Billiards Simulator

2D specular billiards in rectangle, circle, stadium, and ellipse domains with trajectory and phase-space views.

About this tool

Classic billiard dynamics: a point particle moves at constant speed inside a planar domain and reflects specularly off the boundary.

Coordinates & launch angle

  • x₀, y₀ — start position in mathematical coordinates (origin at center, y increases upward on the plot). Use Show coordinate grid to read values from the canvas. Click the canvas while paused to place the start point.
  • Direction (turns) — not degrees: 0 = right, 0.25 = up (90°), 0.5 = left, range 0–1 = one full turn. Phase-space incidence angles use radians internally.

Controls

  • Speed — animation rate only (does not change physics).
  • Max trail points — how many recent bounce segments are drawn; older parts fade off.

Domains

Rectangle, circle, Bunimovich stadium, ellipse, equilateral triangle, and regular n-gon. Current shapes use analytic or edge-based ray casting (fast, exact).

Custom polygons & obstacles

Any simple polygon billiard can be simulated by testing ray hits against each edge (as for the triangle/n-gon here). Obstacles inside the table are possible too: treat each obstacle edge as an extra reflector. Freehand drawing would need a small editor to produce vertex lists; curved or fractal boundaries need specialized root-finding instead of line segments.