Gravitational lensing — live canvas animation example

motion & easing8+
trig, angles & vectors8+
collision detection11+
numbers in motion7+
geometry & shapes8+
generative showpieces13-
handy helpers7+
mass:120rays:50
🌌 Gravitational Lensing — What's going on? Newton said: light has no mass, so gravity cannot pull it. Einstein said: mass curves space itself, and light must follow the curve. Both cannot be right. In 1919, Arthur Eddington photographed stars near the edge of the Sun during a total solar eclipse. The stars appeared shifted from their true positions — exactly as Einstein predicted, and twice what Newton would predict (zero). General relativity won. It has been winning ever since. THE MATH (weak-field / thin-lens approximation): α = 4GM / (bc²) α deflection angle of the light ray G gravitational constant M mass of the lens b impact parameter — the closest approach distance of the ray c speed of light In the animation, all constants are folded into one slider ("mass"). The essential relationship that remains: α ∝ 1/b Rays that pass close to the lens bend the most. Rays that pass far away barely bend at all. This 1/b relationship is what creates the characteristic ring shape. EINSTEIN RINGS When a source, lens, and observer are perfectly aligned, every ray at the same impact parameter b bends by the same angle and converges to a ring on the image plane. The radius of this ring is: θ_E = √( 4GM · D_ls / c² · D_s · D_l ) where D_l, D_s, D_ls are distances between observer, lens, and source. Real examples you can look up: the "Einstein Cross" (quasar Q2237+030), the "Horseshoe Einstein Ring" (SDSS J1148+1930), and thousands more catalogued by Hubble and the James Webb Space Telescope. HOW THIS VISUALIZATION WORKS Parallel horizontal rays enter from the left (the "source" side). At the lens position, each ray is deflected by α = −mass/b toward the lens. The deflected ray then continues in a straight line until it exits the canvas. This is the "thin lens" approximation: we pretend all the bending happens at a single plane (the lens x-position) rather than gradually along the path. It is accurate when the lens is much closer than the source distance — which is true for most real lensing scenarios. CONTROLS • The lens drifts on its own — watch the rays bend and the focus sweep • Drag the glowing dot to reposition it (drift resumes around the new spot) • mass — increase to see stronger bending; watch the rays converge • rays — more or fewer light paths shown