Show Visualization

Mathematical Background

Einstein's Field Equations

The foundation of General Relativity is Einstein's field equations, which relate the curvature of spacetime to the distribution of matter and energy:

Rμν - ½Rgμν + Λgμν = (8πG/c4)Tμν

Where:

  • Rμν is the Ricci curvature tensor
  • R is the scalar curvature
  • gμν is the metric tensor
  • Λ is the cosmological constant
  • Tμν is the stress-energy tensor

The Schwarzschild Solution

For a non-rotating, spherically symmetric mass (like an idealized black hole), Karl Schwarzschild found an exact solution to Einstein's equations. The Schwarzschild metric in standard coordinates is:

ds2 = -(1 - rs/r)c2dt2 + (1 - rs/r)-1dr2 + r2dΩ2

Where:

  • rs = 2GM/c2 is the Schwarzschild radius
  • G is the gravitational constant
  • M is the mass of the object
  • c is the speed of light
  • dΩ2 = dθ2 + sin2θ dφ2

The Schwarzschild radius defines the event horizon - the boundary where spacetime curvature becomes so extreme that nothing can escape.

Geodesic Equations

Objects moving through curved spacetime follow geodesics - the "straightest possible" paths. The geodesic equation is:

d2xμ/dτ2 + Γμαβ(dxα/dτ)(dxβ/dτ) = 0

Where:

  • τ is the proper time along the path
  • Γμαβ are the Christoffel symbols (computed from the metric)

Keplerian Orbits

In flat spacetime (Stage 1), planets follow elliptical orbits described by Kepler's equations. For an ellipse with semi-major axis a and eccentricity e, the position is:

r = a(1 - e cos E)

Where E is the eccentric anomaly, found by solving Kepler's equation:

M = E - e sin E

(M is the mean anomaly, which increases linearly with time)

Simplified Warping Function

For educational purposes, this visualization uses a simplified warping function inspired by the Schwarzschild metric. The actual implementation maps flat coordinates to warped coordinates using:

r' = r · (1 - w · rs/r · e-r/λ)

Where:

  • r is the distance from the center
  • w is the warp factor (0 to 1, stage-dependent)
  • rs is proportional to the mass
  • λ is a scale length for smooth falloff

This creates the characteristic "funnel" shape while remaining computationally efficient for real-time rendering.

Color Mapping: Gravitational Potential

The color gradient represents the Newtonian gravitational potential (a useful approximation):

Φ(r) = -GM/r

This is normalized and mapped to colors: deep blue (low |Φ|) → cyan → yellow → orange → red (high |Φ|). Near the event horizon, colors shift toward red-orange, indicating extreme gravitational energy density.

Numerical Implementation

Key computational techniques used:

  • All trajectories computed using Newton-Raphson iteration for Kepler's equation
  • Float32Array buffers (Typed Arrays) for efficient GPU transfer
  • WebGPU storage buffers hold thousands of grid line segments
  • Each segment rendered as a GPU instance with minimal CPU overhead
Note: This visualization prioritizes graphics over strict physical accuracy. The actual behavior of spacetime near black holes involves effects not shown here, such as frame dragging (for rotating black holes), gravitational time dilation, and relativistic beaming.