DEV Community

Cover image for My Windows wallpaper solves the geodesic equation, live

My Windows wallpaper solves the geodesic equation, live

Geodesics flowing over a torus, a torus knot and other surfaces

My desktop wallpaper is solving differential equations, live, behind my icons.

Each glowing line is a particle sliding along a curved surface (a torus, a knot, a Klein bottle) following the geodesic equation: the path something takes when it goes as straight as it possibly can on a curved space. Same math as light bending around a star, just on a donut.

How it works

For a surface given as a parametric function of (u, v), the geodesic equation says how the particle's velocity changes:

ü^k = -Γ^k_ij · u̇^i · u̇^j
Enter fullscreen mode Exit fullscreen mode

The Γ terms (Christoffel symbols) describe how the surface curves. For the classic surfaces I use exact formulas; for the weirder ones (Boy's surface, Enneper) they come from central finite differences on the metric.

Then it's numerics: step each particle forward with RK4, 0.016 s per frame, keep a fading trail, respawn when the trail runs out. Thirty particles at a time by default.

The wallpaper part

The renderer is Rust + wgpu. To act like a wallpaper it opens a borderless window pinned below every other window, so desktop icons stay clickable. It can span all monitors.

config.toml hot-reloads, so you can change surfaces, colors or the number of geodesics and watch it update without restarting. There are 14 surfaces: torus, sphere, saddle, catenoid, helicoid, hyperboloid, hyperbolic paraboloid, ellipsoid, Enneper, Klein bottle, Boy's surface, torus knot, pseudosphere and trefoil tube.

Headless mode

The same renderer runs offscreen, which is how the GIF above was made:

geodesic-wallpaper --headless --width 480 --height 270 --frames 120 --gif loop.gif
Enter fullscreen mode Exit fullscreen mode

Try it

Windows 10/11, free and MIT licensed:

cargo install geodesic-wallpaper
Enter fullscreen mode Exit fullscreen mode

or grab the zip from the releases. Code and all install options: https://github.com/Mattbusel/geodesic-wallpaper

If you've got a surface you'd like to see geodesics on, tell me and I'll try adding it.

Top comments (1)

Collapse
 
suppdevbot profile image
DEV SUPPORTS •

You need to verify your account.

Enter fullscreen mode Exit fullscreen mode

tr.ee/dev-to