Original interactive widgets

Physics, played with.

Sixty original physics simulations, each implemented from scratch in plain Canvas — no libraries, no tracking. Drag the sliders and the physics is recomputed live every frame. Scroll on for mechanics, waves, thermodynamics, electromagnetism, quantum, relativity, and chaos.

Projectile motion

x = v₀ cosθ · t, y = v₀ sinθ · t − ½ g t²

Orbit (two-body)

F = GMm/r² · drag the radius slider to change the starting orbit.

Two-slit interference

Constructive maxima at d sinθ = mλ. Pattern on a screen at distance L.

Blackbody spectrum (Planck)

B(λ,T) = 2hc²/λ⁵ · 1/(exp(hc/λkT) − 1)

Lorentz boost

γ = 1/√(1 − β²). Rest frame (white) and boosted frame (yellow).

Pendulum (full nonlinear)

θ̈ + (g/L) sinθ = 0. The period grows past the small-angle approximation.

Simple harmonic motion

Mass on a spring: m ẍ = −k x − b ẋ. Watch energy slosh between kinetic and potential.

Wave superposition

Two travelling waves add: y = A sin(kx − ωt) + A sin(kx + ωt) gives a standing wave.

Doppler effect

A source moving through a medium compresses wavefronts ahead and stretches them behind.

Electric field of two charges

Field lines from a positive and a second charge. E = kq/r²; drag the sliders to change them.

Kinetic theory of gases

Elastic particles in a box. Temperature sets average speed; collisions on the walls make pressure.

Quantum particle in a box

Stationary states of an infinite well: ψn = √(2/L) sin(nπx/L), En ∝ n². Probability is |ψ|².

Notes on the physics

Projectile motion. With drag set to zero the trajectory is a textbook parabola; turning drag up bends it forward and shortens the range. Optimal launch angle drifts below 45° once drag is non-zero. The integrator is explicit Euler with dt = 0.01 s, sufficient for visualisation but not for high-precision work.

Two-body orbit. Gravity uses G = 6.674 × 10⁻¹¹ N·m²/kg². The tangential-velocity scale of 1.0 puts the body in a circular orbit at the chosen radius; values below 1 produce ellipses bound to the origin, above ~√2 produce hyperbolic escape.

Two-slit interference. The intensity is |cos(φ/2)|² with φ = 2π d sinθ/λ. Wavelength-to-RGB uses the standard piecewise mapping from 380−780 nm. The fringe-spacing readout uses the small-angle approximation y = λL/d.

Planck spectrum. The peak-wavelength readout uses Wien's displacement law λpeak = b/T with b = 2.898 × 10⁻³ m·K. Total radiated power per unit area is σT⁴ with σ = 5.67 × 10⁻⁸ W/(m²·K⁴).

Lorentz boost. The light cone is fixed (45° lines). The boosted x' axis tilts up with slope β; the t' axis tilts towards the cone with slope 1/β.

Nonlinear pendulum. Four sub-steps per animation frame keep energy close to physical over a few oscillations. The corrected period uses the first nonlinear term, T ≈ T₀(1 + θ₀²/16); at 90° the true period is about 18% above the small-angle T₀.

Simple harmonic motion. The mass obeys m ẍ = −kx − b ẋ, integrated each frame. The two bars show kinetic and potential energy exchanging twice per cycle; with damping b > 0 the total decays. Angular frequency is ω = √(k/m), independent of amplitude — the defining feature of SHM.

Wave superposition. Two sinusoids are summed point by point. Set the second wave's speed to −1 (equal and opposite) and the sum becomes a standing wave with fixed nodes; any other value produces a travelling beat pattern. This is the principle behind standing waves on strings and in resonant cavities.

Doppler effect. The source emits circular wavefronts that all expand at the wave speed. As the source moves, wavefronts bunch up ahead (higher frequency, blueshift) and spread out behind (redshift). When the source outruns its own waves the fronts pile into a Mach cone — the shock wave behind a sonic boom.

Electric field lines. Lines are traced by stepping along the local field direction E = Σ kqᵣ̂/r², starting from rings around each charge. Opposite charges (a dipole) connect; like charges repel and the lines bow away. Line density indicates field strength, and the number of lines scales with charge magnitude.

Kinetic theory. Hard, elastic disks bounce off the walls. Average speed scales with √T, so raising temperature speeds the particles up; the wall-collision rate stands in for pressure, illustrating PV = NkT qualitatively. Particle colour encodes speed (red fast, blue slow).

Quantum particle in a box. The stationary states of an infinite square well are ψₙ = √(2/L) sin(nπx/L) with energies Eₙ ∝ n². The plot shows either the wavefunction ψ or the probability density |ψ|²; state n has n−1 interior nodes, and the energy spacing grows quadratically — the origin of quantised energy levels.

More mechanics

Inclined plane, Atwood, banked curve. These are the classic Newton’s-second-law setups. A block on a slope accelerates at a = g(sinθ − μcosθ) and only moves once θ exceeds the friction angle arctan(μ). The Atwood machine resolves the two-mass system to a = (m₂−m₁)g/(m₁+m₂) with one string tension throughout. A car on a frictionless banked curve needs tanθ = v²/(rg) — the same balance that holds a satellite in orbit, written for a ramp.

Collisions and momentum. Every collision conserves total momentum; whether kinetic energy is also conserved is set by the coefficient of restitution e (1 = elastic, 0 = perfectly inelastic). The 2-D demo shows a special result: two equal masses in an oblique elastic collision always separate at 90°. Newton’s cradle is the chain-collision limit, where one ball in sends one ball out because momentum and energy must balance at once.

Oscillations and chaos. The coupled-oscillator demo splits motion into two normal modes (in-phase and out-of-phase); energy beats between the masses at the difference of the mode frequencies. The driven-resonance curve peaks near the natural frequency ω₀ with a sharpness measured by the quality factor Q ≈ ω₀/γ. The double pendulum has no closed-form solution — a textbook case of deterministic chaos, where tiny changes in the start grow exponentially.

Waves & optics

Standing waves, beats, and pulses. A string fixed at both ends only supports wavelengths λₙ = 2L/n, the harmonics. Two waves of nearly equal frequency interfere into beats whose envelope throbs at |f₁ − f₂|. A pulse reflecting from a fixed end inverts (a π phase shift) while a free end reflects upright — the boundary condition decides the sign.

Refraction, lenses, diffraction, polarization. Snell’s law n₁sinθ₁ = n₂sinθ₂ bends light at an interface and, beyond the critical angle, gives total internal reflection (the basis of optical fibre). The thin-lens equation 1/f = 1/dₒ + 1/dᵢ locates images. Single-slit diffraction puts its first dark fringe at sinθ = λ/a, so a narrower slit spreads light more. Malus’s law I = I₀cos²θ sets how much light a polarizer passes. The Fourier demo builds a square wave from odd harmonics, showing synthesis and the stubborn Gibbs overshoot.

Thermodynamics & statistical physics

From molecules to laws. The Maxwell–Boltzmann curve gives the spread of molecular speeds; its most-probable speed scales as √(T/m). Brownian motion — the random walk of a large particle kicked by molecules — has a mean-square displacement that grows linearly in time (Einstein’s 1905 proof that atoms are real). Heat diffusion obeys ∂T/∂t = α∂²T/∂x², always smoothing a hot spot toward uniformity — a visible face of the second law. The Carnot PV cycle sets the ceiling on engine efficiency, η = 1 − T₋/Tₐ, and the piston demo makes Boyle’s law PV = NkT tangible as particles strike a moving wall.

Electromagnetism

Fields, forces, and circuits. A charge in a magnetic field feels F = qv×B, curving into a circle of radius r = mv/(qB) — the principle of cyclotrons and mass spectrometers. Cross an electric and magnetic field and only one speed, v = E/B, passes undeflected (a velocity selector). RC circuits charge with time constant τ = RC (63% after one τ); LC circuits oscillate at f = 1/(2π√LC) as energy trades between the capacitor’s electric field and the inductor’s magnetic field. Faraday’s law, EMF = −dΦ/dt, means only a changing flux drives a current. An electromagnetic wave is the result: E and B oscillate in phase, perpendicular to each other and to the travel direction, at speed c = λf.

Modern physics, quantum & relativity

Quanta. The photoelectric effect (KE_max = hf − φ) shows light arriving in discrete packets: below a threshold frequency, no electrons escape however bright the source — the observation that won Einstein the Nobel Prize. The Bohr levels Eₙ = −13.6/n² eV fix the photon energies of atomic spectra. Quantum tunnelling lets a particle cross a barrier taller than its energy, with a probability that falls exponentially with width — behind alpha decay and the scanning tunnelling microscope. A wave packet illustrates the uncertainty principle: localizing a particle spreads its momentum, so the packet disperses. Radioactive decay follows N = N₀(½)^(t/t½): each atom decays at random, yet the half-life is fixed.

Relativity. The light-clock demo shows time dilation directly — a clock moving at speed βc ticks slow by γ = 1/√(1−β²). Velocities combine relativistically as w = (u+v)/(1+uv/c²), never exceeding c even when the naive sum would. The de Broglie relation λ = h/p ties the lab together, giving every particle a wavelength and explaining why everyday objects look classical: their λ is unimaginably small.

Astrophysics & chaos

Gravity and non-linearity. The three-body simulation has no general analytic solution — small differences explode, the seed of chaos theory. Kepler’s second law (equal areas in equal times) follows from angular-momentum conservation, so a planet races through perihelion and dawdles at aphelion. The logistic map xₙ₊₁ = rxₙ(1−xₙ) compresses the whole route from order to chaos through period-doubling as r grows, while the Lorenz attractor — a stripped-down weather model — traces a path that never repeats yet stays bounded: the original “butterfly effect.”

A note on method. Every simulation integrates the equations of motion live with simple explicit schemes (Euler or sub-stepped Euler) chosen for clarity, not numerical precision. They are built for intuition — to show how a system behaves as you change its parameters — not for publication-grade accuracy. For exact figures, use the linked calculators and the formula library.

Where each widget links into the library