This evening I wanted to satisfy a curiosity: to see the solar system as it really is, not the way primary school textbooks draw it. No concentric circles with the planets lined up, no Sun sitting still at the centre of the universe. Real orbits, real positions, and a Sun that moves.
I opened Claude and asked it to build it with me. The result is Solar Drift, a 3D orrery that runs in the browser. But the interesting part was not so much the code: it was the chance to brush up on some celestial mechanics I had left gathering dust since school.
Orbits are not circles
The first thing to get right is the best known and the most ignored in graphical depictions. Planetary orbits are ellipses, with the Sun at one of the two foci, not at the centre. That is Kepler’s first law.
How elliptical they are depends on the planet. The Earth has an eccentricity of about 0.017: almost a circle, and yet in early January we are 147 million km from the Sun and in early July 152 million. Mars reaches 0.093. Mercury 0.206, the highest value. Yet even its orbit looks like a circle to the eye: the flattening depends on the square of the eccentricity and is barely 2%. What you do notice in the simulation is something else: the Sun is not at the centre of the orbit but shifted by a fifth of the radius, and Mercury’s distance ranges from 0.31 to 0.47 AU. The seasons, incidentally, have nothing to do with distance: they come from the tilt of the Earth’s axis.
Then there are the inclinations. The orbits do not all lie on the same plane: Mercury is tilted 7° to the ecliptic, the others by a few degrees. Not much, but enough to notice when you rotate the view edge-on.
Kepler: three laws and one equation
A quick refresher, because each of the three laws has a visible effect in the application.
- First law: orbits are ellipses with the Sun at one focus.
- Second law: the line joining the Sun and a planet sweeps out equal areas in equal times. In practice: a planet speeds up when it is close to the Sun (perihelion) and slows down when it is far (aphelion). The Earth goes from about 30.3 to 29.3 km/s.
- Third law: the square of the period is proportional to the cube of the semi-major axis. That is why Neptune, thirty times farther out than the Earth, takes almost 165 years to complete one orbit.
The second law is the one that complicates things. If the planet does not move at constant speed, you cannot just advance an angle by a few degrees each frame. You have to solve Kepler’s equation:
M = E − e · sin(E)
M is the mean anomaly, which grows uniformly with time and is easy to compute. E is the eccentric anomaly, the one you actually need to find the position on the ellipse. The catch is that the equation cannot be inverted in closed form: given M, there is no formula that returns E. It is solved by successive approximations with Newton’s method, which for eccentricities as small as the planets’ converges in three or four iterations. Solar Drift does this for every planet, at every step of the simulation.
Real data, today’s positions
To avoid making anything up, the orbits start from the orbital elements published by NASA’s JPL: semi-major axis, eccentricity, inclination, mean longitude, longitude of perihelion and of the ascending node, referred to the J2000 epoch (1 January 2000, 12:00). Each one also comes with its rate of change per century, because the orbits slowly drift over time due to mutual perturbations.
When it opens, the simulation starts from the current date and time, so the planets are where they are right now. The ephemeris panel shows distances and speeds in real time, and you can speed up or stop the flow of time.
The Sun does not stand still
This is the part I was most interested in. The Sun, and the whole solar system with it, orbits the centre of the Milky Way at about 230 km/s, at a distance of roughly 26,700 light years. One full lap, the so-called galactic year, takes about 225 million years. Since it formed, the Sun has completed around twenty of them.
In more familiar units: every year the solar system covers about 48.5 astronomical units, that is 48 and a half times the Earth-Sun distance. It follows that the planets never trace the same path through space twice: their trajectories are helices unrolling behind the Sun.
There is a detail that many viral animations get wrong. The plane of the orbits is neither perpendicular to the direction of travel nor aligned with it: it is tilted by about 60° to the galactic plane. So the planets do not chase the Sun like a comet’s tail. They circle it on a tilted plane while the whole system moves forward. In the simulation, the direction of motion, towards the constellation Cygnus, and the direction of the galactic centre are the real ones.
The galactic drift has its own slider. At the real speed the trails would be so long they would turn into nearly straight lines, and the orbits would disappear. By default it is scaled down, so you can read both things: the lap around the Sun and the progress through the galaxy.
The compromises
Realistic does not mean perfect. Distances and orbit shapes are to scale, but the bodies are not: at true size the Sun would be a dot and the Earth invisible. In the simulation the Sun is enlarged about 20 times and the Earth about 290. JPL’s orbital elements are an approximation meant for the 1800-2050 range: perfectly fine for a visualisation, less so for predicting an eclipse. There are no moons, and no oscillation of the Sun above and below the galactic plane.
AI as an excuse to study
I have already written about several projects built with AI on this site. This time, though, the value was not in the finished product but in the journey. To get a correct depiction I had to understand what to ask for, and to understand that I had to revise things I had forgotten: what the anomalies are, why Kepler’s equation has no analytical solution, how you go from the plane of the orbit to the plane of the ecliptic.
It is a way of using these tools that I find underrated. Not to have things done for you, but as an excuse to get your hands back on something worth knowing. A bit of astronomy never hurts.
Controls
- Drag to change viewpoint, scroll wheel to zoom, space bar to pause
- Zoom presets: Inner, Jupiter, Full
- Sliders for time rate, galactic drift and trail length








