Day 3: Making the Moon actually orbit (ugh)
Today i had to do two things. First, finishing the terrain feature from Day 2 (i put it off), and building a real time astronomical engine so the Earth and Moon are where they actually are.
Wiring up the terrain analysis
First I connected Day 2’s landing-point analysis to the frontend. So now when you select a landing area, you click a button that says “Search Area”. It will then pull the most optimal exact landing coordinates from precomputed data (for reference, I made a simple python script that downloaded official NASA .TIFF files for areas of interest, analyzed each pixel that shows slope and such, and found the most optimal landing point in that area).
So I wanted to test if it worked. I plugged in the coordinates into a moon map I found online, and zoomed in on Nobile Rim 2 and its exact marker, and you can see why the algorithm picked that spot. The marker lands on a smooth flat patch while the crater walls and shadowed pits around it get avoided.
The orbital model
Here is the bigger piece. I wanted the Earth and Moon to be synced to real world time. So I built a standalone module that turns any timestamp into the correct geometry. This includes Earth’s rotation angle, the Moon’s position in its orbit, the tidal-locking, the Sun direction, and the moon phase.
The positions use standard mean orbital elements, the Meeus algorithms, which are accurate to about a degree. Not full JPL-ephemeris precision, but it’s fine for now. Exact placement is a later upgrade once the Horizons backend is in.
Verifying it’s actually right
This is the part I’m happy about. Instead of building the whole 3D scene and really really hoping the math was right, I kept the orbital model separate and tested it against reality first. Sooooo i fed it the current time and checked the output: 402,389 km Moon distance (real range is 356k–406k), and it reported a waning gibbous moon at 97% illuminated. Then I checked the actual moon phase for tonight. Waning gibbous, 97 to 99%. It matched. YES!!!
The time engine
I also built the simulation clock that’ll drive everything: play/pause, speed control from real time up to a week per second, a live “follow the real clock” mode, and jump-to-any-date. If you’ve ever played Universe Sandbox, it’s like that. Time always runs at whatever rate you set, and you pause it yourself if you want the Moon to hold still. Got it ticking cleanly at a steady one second per second, verified against wall clock UTC.
The unglamorous part
Also spent a genuinely stupid amount of time untangling git after accidentally committing a 250MB Python virtual environment and a folder of giant NASA GeoTIFFs. GitHub has a 100MB file limit, which I discovered the hard way when it rejected the push. Lesson permanently learned: write the .gitignore first.
Next
Wire the verified orbital model into the actual 3D scene, the literal Moon-orbits-Earth motion, tidal locking, and the time-control bar. Then on to the launch window calculator with real JPL Horizons ephemeris.