Schwarzschild Geodesic Visualization in C++/WebAssembly
reddit.com·1d·
Discuss: r/programming
🖼️Terminal Graphics
Preview
Report Post

I attempted to build a real-time null geodesic integrator for visualizing photon paths around a non-rotating black hole. The implementation compiles to WebAssembly for browser execution with WebGL rendering.

Technical approach:

- Hamiltonian formulation of geodesic equations in Schwarzschild spacetime

- 4th-order Runge-Kutta integration with proximity-based adaptive stepping

- Analytical metric derivatives (no finite differencing)

- Constraint stabilization to maintain H=0 along null geodesics

- LRU cache for computed trajectories

The visualization shows how light bends around the event horizon (r=2M) and photon sphere (r=3M). Multiple color modes display termination status, gravitational redshift, constr...

Similar Posts

Loading similar posts...