How the Starflight Simulator Works

This page gives the equations and data behind Starflight: Flying Near Light Speed, the simplifications we made, and the tests the code passes. The simulator, its test programs and this write-up were built with Claude Opus 5.5. The main page explains the same ideas without equations.

We use c = 1. The stars, the Milky Way's gas and dust, and the Sun are taken to be at rest together; the ship moves relative to them with velocity βv̂. Directions are unit vectors in the ICRS equatorial frame. The speed is carried as the rapidity η = artanh β, so γ = cosh η, βγ = sinh η, and the Doppler factor straight ahead is eη. The speed slider runs in η, up to η = 8 (γ ≈ 1,500), which keeps every formula below accurate at any speed.

Where the Light Comes From: Aberration

Light from a star in direction n (in the stars' frame), at angle θ from the direction of travel, arrives at the moving ship from direction d at angle θ′, in the same plane, with

cos θ′ = (cos θ + β) / (1 + β cos θ)   ⟺   tan(θ′/2) = e−η tan(θ/2).

The second form is the one the code uses. It is exact, it keeps its accuracy straight ahead and straight behind at any speed, and it shows two properties directly. The circle θ = 90°, the stars that were beside the ship, appears at tan(θ′/2) = e−η, that is cos θ′ = β, so everything that was in front of the ship fits within arccos β of the heading. And in a stereographic projection centred on the heading, where a direction at angle θ is drawn at radius 2 tan(θ/2), the whole effect is a uniform zoom by e−η: aberration is a conformal map of the sky (a Möbius transformation), which keeps small shapes and turns circles into circles. The "Zoom in to undo the crowding" switch magnifies the wide-lens view by eη, which cancels it exactly when looking straight ahead.

To keep single-precision graphics cards accurate for the tiny angles that matter at high speed, tan(θ/2) is computed from the cross product rather than from cos θ: |n × v̂| / (1 + n·v̂) ahead and (1 − n·v̂) / |n × v̂| behind.

The Doppler Factor

The ratio of received to emitted frequency is

D = γ (1 + β cos θ) = 1 / [γ (1 − β cos θ′)] = (eη + e−η t2) / (1 + t2),    t = tan(θ/2),

which runs from eη straight ahead to e−η straight behind, and equals 1 at cos θ′ = (1 − 1/γ)/β. Specific intensity divided by frequency cubed, Iν/ν3, is the same in every frame, so a source of spectral radiance Iν(ν) is seen with I′ν(ν) = D3 Iν(ν/D), or in wavelength I′λ(λ) = D5 Iλ(Dλ). A blackbody at temperature T is therefore seen as a blackbody at DT.

The Stars: Catalogues, Brightness and Colour

Catalogue. The Henry Draper Catalogue and its Extension (Cannon & Pickering 1918–1924; Cannon 1925–1936), in the machine-readable edition prepared at NASA's Astronomical Data Center (Roman & Warren 1985): 269,694 stars with a usable magnitude. It is public domain. Positions are for equinox B1900, to 0.1 minute of right ascension and 1′ of declination, and are precessed to J2000 with the IAU 1976 angles (Lieske et al. 1977); the century of proper motion since 1900 is ignored, which moves the nearest stars by a few arcminutes. The V magnitude is the catalogue's photovisual magnitude, or its photographic magnitude minus the colour of the spectral type where only that was measured; both are within a few tenths of a magnitude of modern V. For about 40 named, nearby and bright variable stars, modern published values of V, temperature and distance are used instead (individual facts, rounded). Each star is packed into 8 bytes (position, distance, magnitude, temperature).

Temperatures. From the Harvard spectral class: O to F stars take main-sequence temperatures (Pecaut & Mamajek 2013; Mamajek's 2022 table); G, K and M stars, which in a catalogue this bright are mostly giants, take typical giant temperatures (Alonso, Arribas & Martínez-Roger 1999 for K; Fluks et al. 1994 for M), interpolated between subclasses. These are typical values for each class, not measurements of each star; the named stars use measured temperatures.

Distances. Published distances for the named and nearby stars (all those within about 5 pc that are in the catalogue, and the bright named stars); all others are placed at 1 kpc, which keeps them effectively fixed during a journey of a few light-years. The Sun is added as a star of absolute magnitude 4.83 and B − V 0.65, shown once the ship is more than 0.015 pc from it.

Brightness. A star's flux at rest is its catalogue V magnitude (2.54 × 10−6 lux at V = 0), scaled by distance during a journey. Moving, its spectrum is that of a blackbody at DT, and its solid angle shrinks by D2, so its visible flux changes by

F′ / F = Y(DT) / [Y(T) D2],

where Y(T) is the luminance of a blackbody at T (the Planck spectrum integrated against the CIE 1931 ȳ curve, from a 1,024-step table built at startup). Bolometrically the flux grows as D2, but the visible part peaks where DT ≈ 16,500 K and then falls as 1/D: a 3,000 K star brightens by up to 4.2 magnitudes (at D = 5.5), a Sun-like one by 1.2 (at D = 2.9), a 10,000 K one by only 0.2, and at D = 100 a Sun-like star is down to a fifth. Because stars crowd together as D2 per unit solid angle, the starlight per unit area of sky still grows, as Y(DT)/Y(T).

Colour. The display colour of a blackbody at DT, from the CIE 1931 colour-matching functions (analytic fit of Wyman, Sloan & Shirley 2013) and the sRGB matrix, white-balanced so a 5,800 K blackbody is white, as on our Fly-By page.

Journey parallax. During a journey the ship is at s = x v̂; each star's direction is that of X − s and its magnitude M + 5 log10(|X − s| / 10 pc). The stars' own motions are ignored.

The Light Spread Across the Sky

For every pixel, the direction d is taken back to the stars' frame with −η (n = aberration of d by −η), and four components are added, each seen through its own Doppler factor with I′λ(λ) = D5 Iλ(Dλ), integrated against the CIE curves into a luminance and a colour. For the isotropic components these are one-dimensional tables in log D (1,024 steps), built in the browser at startup; the Milky Way's starlight needs a two-dimensional table in log D and reddening.

The cosmic microwave background. A blackbody at T0 = 2.7255 K (Fixsen 2009) in its own frame. The Sun moves through it at 369.82 km/s toward (l, b) = (264.021°, 48.253°) (Planck 2018: dipole 3,362.08 µK). The temperature seen by the ship is T = T0 D1 D2, with D1 the ship's Doppler factor relative to the Sun for direction d, and D2 the Sun's relative to the CMB frame for direction n: the exact composition of the two boosts. At rest this is the measured dipole.

The light of all galaxies (the extragalactic background light). Taken to be isotropic in the CMB frame, with νIν from the integrated galaxy counts of Driver et al. (2016, their table 3, 0.153–504 µm: 1.45 nW m−2 sr−1 in the far ultraviolet, 10.4 at 1 µm, 16.5 at 160 µm), the FIRAS fit of Fixsen et al. (1998), Iν = 1.3 × 10−5 (ν/ν0)0.64 Bν(18.5 K), above 504 µm, and zero below the Lyman limit at 91.2 nm.

The Milky Way's dust. Its 100 µm brightness I100 = E(B−V)/0.0184 from the all-sky reddening map of Schlegel, Finkbeiner & Davis (1998; HEALPix version from NASA's LAMBDA archive), with the dust-temperature correction set to 1, stored as a 1,024 × 512 galactic map (0.35° per texel). Its spectrum is the measured emission of dust in the diffuse high-latitude medium (Compiègne et al. 2011, table 2: DIRBE, FIRAS-derived and WMAP points from 3.5 µm to 4.9 mm), divided by its 100 µm value, interpolated in log–log, falling steeply below 3 µm, and then smoothed with a Gaussian of 0.15 dex in wavelength. The points are averages over broad bands; without smoothing, the corners of the interpolated curve, swept through the visible by the changing Doppler factor, painted a false green and magenta ring around the glow. The real spectrum has strong bands from carbon molecules (PAHs) at 6.2, 7.7, 8.6, 11.3 and 12.7 µm that the broad bands only partly capture, so between roughly 98% and 99.5% of light speed, where those wavelengths are seen as visible light, the dust's glow is probably underestimated by a few times; and dust in star-forming regions like Orion's is warmer than this average. The same spectrum is used everywhere.

The Milky Way's starlight. The COBE/DIRBE zodi-subtracted mission average map at 1.25 µm (Hauser et al. 1998; Kelsall et al. 1998; from NASA's LAMBDA archive, with LAMBDA's table of pixel-centre coordinates), from which the catalogue stars are removed: each star's 1.25 µm flux is estimated from V and its temperature as a blackbody (Fν(V = 0) = 3,640 Jy), spread with a 0.7° Gaussian beam and subtracted (catalogue stars make up 16% of the all-sky mean of 0.50 MJy/sr); what remains near bright stars is removed with a 2° median filter. The spectrum of this unresolved starlight is that of the interstellar radiation field near the Sun (Mathis, Mezger & Panagia 1983: three diluted blackbodies at 7,500, 4,000 and 3,000 K; their separate ultraviolet component is left out, which matters only behind the ship), and the dust mixed in with the stars dims it by (1 − e−τ)/τ, with τλ = Aλ/1.086 from the SFD reddening and the extinction curve of Cardelli, Clayton & Mathis (1989, RV = 3.1), normalised at 1.25 µm. This gives the dark rifts of the Milky Way in visible light without drawing them.

Heading toward Orion's Belt, the Milky Way's starlight is the brightest of these straight ahead up to D = 12 (98.6%), the dust from there to D = 850 (γ = 426), and the CMB above that. Toward the north galactic pole, the dust takes over at D = 17 (99.3%), the galaxies' light at γ = 204, and the CMB from γ = 338. The light of the galaxies, being isotropic, is outshone by the CMB everywhere above D ≈ 675 (γ ≈ 340). The cosmic microwave background reaches the Sun's surface temperature, 5,772 K, straight ahead at D = 2,118, γ = 1,059: the region more than half as hot has a radius of 1/γ = 3.25′, a fifth of the Sun's width, and the peak of the spectrum, at 1.06 mm at rest, arrives at 502 nm.

From Light to Pixels

Projections. The wide-lens view is stereographic about the camera axis (radius 2 tan(α/2)); the whole-sky view is azimuthal equidistant about the heading (radius ∝ angle, the rim straight behind); the galactic map is Mollweide's equal-area projection. Each has an exact solid angle per pixel, Ωpix = (1 + r2/4)−2/k2, π2 sin a/(a k2) and 2/k2 respectively, with k pixels per projection unit.

Linear light. Everything is added up as light, in a 32-bit floating-point buffer where the graphics card can blend them (16-bit otherwise). Diffuse light contributes its luminance. Each star contributes its illuminance E spread over a small point-spread function that keeps all of its light: a Gaussian core of σ = 0.75 CSS pixels, plus, if switched on, a glare halo (a fraction g of the light, exponential with a 3-pixel scale, the only cosmetic step), divided by the local Ωpix. Crowded stars therefore add up to the right surface brightness, and switching glare off or on doesn't change the total.

Exposure and tone curve. A pixel's linear value is x = L/Lref, where Lref is chosen so that the core of a star of the faintest magnitude shown (default 6.5, the naked-eye limit) peaks at x = 1 at the centre of the picture; Lref therefore grows as the square of the zoom, and narrower views show the glow darker. One curve then maps every pixel to the screen: level = ln(1 + 6x)/ln(1 + 6 × 4,000), keeping the hue; where a colour would exceed the display's range it is scaled down and white is added back to keep its luminance, so very bright light turns white without inventing new hues (clipping red, green and blue separately did). In the default view, in a typical window, Lref ≈ 3 × 10−4 cd/m², close to the brightness of the Milky Way, so a glow that faint is just visible. In the whole-sky and map views each pixel covers more sky and Lref is lower, so the same glow looks brighter, as in a longer exposure. True luminances are in the panel ("Glow straight ahead").

Overlay. Constellation lines are sampled along great circles in the stars' frame and carried through the same aberration; the dashed ring is the image of the circle θ = 90°.

The 1 g Journey

The ship accelerates at a constant proper acceleration g = 9.80665 m/s2 = 1.0323 ly/yr2 for the first half of the distance L and decelerates for the second. In hyperbolic motion the rapidity grows evenly with the ship's own time τ, η = gτ, the distance covered is (cosh η − 1)/g and Earth's time is sinh η/g; at halfway cosh ηmax = 1 + gL/2. For Alpha Centauri, 4.4 light-years away, the ship reaches 95.2% of light speed, and the trip takes 3.58 years aboard and 6.00 years on Earth (the simulator stops 1% short of the star). The animation runs evenly in ship time. Because what an observer sees at an instant depends only on their velocity at that instant, the view of an accelerating ship is exactly the view from an inertial ship with the same velocity.

Verification

A separate Python program (tools/starflight/reference.py, numpy only, sharing no code with the page) works the physics out a different way: it follows each photon's energy–momentum 4-vector through explicit Lorentz transformations in 50-digit decimal arithmetic, measures a star's brightness by integrating its boosted spectrum over the boosted outline of its disc, integrates the 1 g journey step by step, and builds the sky ahead from the data files. A test page runs the site's physics module against it in headless Chrome, and a second set of tests reads back what the graphics card draws.

TestResult
Apparent direction of 280 rays, speeds up to γ ≈ 1,060 (Doppler factor 2,100), including directions within 10−4 of straight ahead and behindAgree with the explicit boost to 6 × 10−13 rad
Doppler factor, from the star's direction and from the seen directionAgree to 3 × 10−14
Star brightness factor Y(DT)/[Y(T)D2] vs the boosted disc, integrated (30 cases, 3,000–30,000 K, D = 0.3–100)Agree to 1.5 × 10−5; the disc's solid angle shrinks as D−2 to 1.3 × 10−5
CMB temperature in 125 directions, with and without the Sun's motion (two boosts)Agree to 3 × 10−14
CMB energy density seen by a moving observer, integrated over the sky, vs γ2(1 + β2/3)Agree to 10−8 (β = 0.5, 0.9) and 10−6 (β = 0.99), limited by the integration grid
Luminance of the boosted galaxy light, dust, Milky Way starlight and CMB, D = 0.2–2,118Agree to 0.04%; the tables the graphics card reads, to 0.3%
1 g journeys to Alpha Centauri, Sirius, Tau Ceti and Vega: ship time, Earth time, top speedAgree with step-by-step integration to 3 × 10−10
The wide-lens view looking ahead is an exact zoom by e−η; aberration keeps angles (small triangles)To 5 × 10−12; triangle angles change in proportion to the triangles' size (2 × 10−5 rad at 10−5 rad), i.e. not at all in the limit
Pixel solid angle of the three projections vs a numerical JacobianAgree to 5 × 10−6
Graphics card: the light drawn, read back and added up, vs the summed illuminance of every star in view (7 cases, all projections, rest to 99.99%, with and without glare)Within 0.4%; within 3% where stars sit partly in the edge margin left out of the sum
Graphics card: positions of bright stars in rendered images vs positions predicted independently (rest, 90%, 99%)Median 0.7 pixels, largest 1.2 pixels; a few predicted stars are not found as separate spots because they merge with brighter neighbours in the image
Graphics card: luminance at the centre of the picture, one diffuse component at a time, vs the reference (99% and 99.9%)Galaxies 0.1%; Milky Way starlight 0.5%; dust within 4% (map texture sampled bilinearly vs nearest-texel)

The graphics card tests were run both with Chrome's software renderer and on a laptop's Intel graphics through Direct3D 11, the path Chrome takes on Windows. On the Intel GPU, 16-bit blending lost 3–4% of the light where thousands of faint stars pile into one pixel, which is why the page uses 32-bit blending where it can. Frame rates there were 50–250 frames per second, depending on the view and what else the laptop was doing. Every number quoted on the main page comes from these result files or from facts.txt.

Notes on the Everyday Numbers

References and Data

  1. Bradley, J. (1729). An account of a new discovered motion of the fix'd stars. Philosophical Transactions of the Royal Society, 35, 637–661. DOI
  2. Einstein, A. (1905). Zur Elektrodynamik bewegter Körper. Annalen der Physik, 17, 891–921 (§7: aberration and the Doppler principle). DOI
  3. Sänger, E. (1962). Some optical and kinematical effects in interstellar astronautics. Journal of the British Interplanetary Society, 18, 273–277.
  4. Pohl, F. (1972). The Gold at the Starbow's End. Analog, March 1972.
  5. McKinley, J. M., & Doherty, P. (1979). In search of the "starbow": the appearance of the starfield from a relativistic spaceship. American Journal of Physics, 47, 309–316. DOI
  6. Planck Collaboration (2014). Planck 2013 results. XXVII. Doppler boosting of the CMB: Eppur si muove. Astronomy & Astrophysics, 571, A27. DOI
  7. Planck Collaboration (2020). Planck 2018 results. I. Overview and the cosmological legacy of Planck. Astronomy & Astrophysics, 641, A1 (CMB dipole). DOI
  8. Fixsen, D. J. (2009). The temperature of the cosmic microwave background. The Astrophysical Journal, 707, 916–920. DOI
  9. Cannon, A. J., & Pickering, E. C. (1918–1924). The Henry Draper Catalogue. Annals of the Harvard College Observatory, 91–99; Cannon, A. J. (1925–1936). The Henry Draper Extension. Annals, 100. Machine-readable edition: Roman, N. G., & Warren, W. H. Jr. (1985, rev. 1989), NASA Astronomical Data Center (CDS catalogue III/135A).
  10. Lieske, J. H., et al. (1977). Expressions for the precession quantities based upon the IAU (1976) system of astronomical constants. Astronomy & Astrophysics, 58, 1–16. ADS
  11. Alonso, A., Arribas, S., & Martínez-Roger, C. (1999). The effective temperature scale of giant stars (F0–K5). Astronomy & Astrophysics Supplement, 140, 261–277. DOI
  12. Fluks, M. A., et al. (1994). The photospheric spectra of M giants. Astronomy & Astrophysics Supplement, 105, 311–336. ADS
  13. Pecaut, M. J., & Mamajek, E. E. (2013). Intrinsic colors, temperatures, and bolometric corrections of pre-main-sequence stars. The Astrophysical Journal Supplement, 208, 9 (with Mamajek's dwarf sequence table, version 2022.04.16). DOI
  14. Ballesteros, F. J. (2012). New insights into black bodies. EPL, 97, 34008. DOI
  15. Driver, S. P., et al. (2016). Measurements of extragalactic background light from the far UV to the far IR from deep ground- and space-based galaxy counts. The Astrophysical Journal, 827, 108. DOI
  16. Fixsen, D. J., et al. (1998). The spectrum of the extragalactic far-infrared background from the COBE FIRAS observations. The Astrophysical Journal, 508, 123–128. DOI
  17. Schlegel, D. J., Finkbeiner, D. P., & Davis, M. (1998). Maps of dust infrared emission for use in estimation of reddening and cosmic microwave background radiation foregrounds. The Astrophysical Journal, 500, 525–553 (HEALPix version from LAMBDA). DOI
  18. Compiègne, M., et al. (2011). The global dust SED: tracing the nature and evolution of dust with DustEM. Astronomy & Astrophysics, 525, A103. DOI
  19. Hauser, M. G., et al. (1998). The COBE Diffuse Infrared Background Experiment search for the cosmic infrared background. I. Limits and detections. The Astrophysical Journal, 508, 25–43. DOI
  20. Kelsall, T., et al. (1998). The COBE Diffuse Infrared Background Experiment search for the cosmic infrared background. II. Model of the interplanetary dust cloud. The Astrophysical Journal, 508, 44–73 (zodiacal light subtracted from the maps used). DOI
  21. DIRBE zodi-subtracted mission average maps and sky-map coordinate tables, NASA LAMBDA (lambda.gsfc.nasa.gov).
  22. Mathis, J. S., Mezger, P. G., & Panagia, N. (1983). Interstellar radiation field and dust temperatures in the diffuse interstellar matter and in giant molecular clouds. Astronomy & Astrophysics, 128, 212–229. ADS
  23. Cardelli, J. A., Clayton, G. C., & Mathis, J. S. (1989). The relationship between infrared, optical, and ultraviolet extinction. The Astrophysical Journal, 345, 245–256. DOI
  24. Górski, K. M., et al. (2005). HEALPix: a framework for high-resolution discretization and fast analysis of data distributed on the sphere. The Astrophysical Journal, 622, 759–771. DOI
  25. Wyman, C., Sloan, P.-P., & Shirley, P. (2013). Simple analytic approximations to the CIE XYZ color matching functions. Journal of Computer Graphics Techniques, 2(2), 1–11. Link
  26. Rindler, W. (2006). Relativity: Special, General, and Cosmological, 2nd ed., Oxford University Press (aberration, Doppler effect, hyperbolic motion).
← Back to the simulator Beginner's guide →