Visualizations
270 / 500

270 · Astronomy

Comet

A comet rounds the Sun and grows a straight blue ion tail and a curved dust tail.

The nucleus follows an exact Kepler orbit, and time runs slower near the Sun so perihelion gets the screen time. Sublimating ice lifts dust off the day side, and sunlight pushes each grain outward with a fraction beta of solar gravity, so every grain moves on its own Kepler orbit with an effective GM of 1 - beta and is integrated with leapfrog steps sized to its distance. The broad, curved yellow tail is just where forty thousand grains end up, each smeared into a short streak along its drift from the nucleus: small grains race outward, big ones barely leave the orbit. Ions are swept up by the solar wind, computed in closed form from their birth so the blue tail stays straight, aberrated and kinked by gusts. An overlay draws syndynes and synchrones from tracer grains, and an inset ray traces a rotating two-lobed nucleus venting jets from its sunlit side.

Try it. Drag the perihelion marker to change how close the comet passes and where; the arrow keys do the same. Press S (or click empty space) to show syndynes and synchrones, and Space to speed up. Left alone, each orbit gets a new perihelion.

  • Kepler's equation
  • Radiation pressure beta
  • Syndynes and synchrones
  • Ray traced ellipsoid union

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a comet with a dust tail and an ion tail made from real particle physics, using JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Use units where the Sun's GM is 1 and distances are in AU. Put the Sun at the center of a canvas that fills the window and give the comet an eccentric orbit, with perihelion about 0.4 AU and aphelion about 5 AU.
- Move the comet exactly along its orbit by solving Kepler's equation E - e sin E = M with a few Newton steps each frame.
- While the comet is within about 3 AU, release dust grains from it every frame, with the comet's velocity plus a small random kick toward the Sun. Give each grain a random beta between 0 and 1: sunlight cancels that fraction of the Sun's gravity, so the grain feels GM = 1 - beta.
- Step every grain with leapfrog, using smaller steps closer to the Sun, and draw them as faint warm yellow dots. A curved, fanned dust tail should appear on its own.

Once that works, make it beautiful:
- Add an ion tail: ions start at the comet and move straight away from the Sun at about 13 AU per time unit, fading quickly. Draw them in blue.
- Accumulate grains and ions into a low-resolution brightness buffer, blur it, and draw it additively over a starfield with a glowing Sun.
- Slow time down near the Sun and speed it up far away, and let the camera zoom to frame the comet and its tails.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as drawing syndyne and synchrone lines, a draggable perihelion, or kinks that travel down the ion tail from gusts in the solar wind.
PreviousAmes RoomIdentical twins become a giant and a child inside a room that only looks square. NextLava LampGlowing blobs that merge and split like a lava lamp.

Related visualizations

  • Ground TracksAstronomy The snakes, loops and figure eights real orbits trace over a turning world.
  • AnalemmaAstronomy A garden noon mark traces the figure eight of Earth's orbit, one stud a day.
  • Galaxy CollisionAstronomy Two spiral galaxies collide and fling out long tidal tails.
  • Grand TourGames Plan a probe's slingshot route past Jupiter, Saturn, Uranus and Neptune.
  • Kirkwood GapsAstronomy Thousands of asteroids and Jupiter's resonances carving gaps into a featureless belt.
  • Retrograde LoopsAstronomy Why Mars backs up against the stars, drawn by Copernicus and Ptolemy side by side.
  • Planet ForgeAstronomy A dusty disk grows rocky worlds, ice giants and gas giants by N-body accretion.
  • TotalityAstronomy A total solar eclipse from a lakeshore, driven by the real shadow geometry.
  • Solar SurfaceAstronomy Granulation, sunspots and flaring magnetic loops at the Sun's limb, in three wavelengths.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs