I've always been interested in science, but somehow I was never super into astronomy or space travel. So when I was tasked with building all the interactive elements for NASA's lessons on Khan Academy, I had to learn a fair bit of basic mechanics. And as with pretty much everything, the more I learnt, the more interesting I found the topic. The landing of the Curiosity rover on Mars in particularly was amazing.
The NASA tutorial is split into two lessons:
Measuring the universe
This lesson gives a historical perspective on how we built an understanding of the solar system from relatively simple observations. It features several programs with orbits, which I tried to make as accurate as I reasonably could. This meant having to learn a lot about ellipses.
Modeling the solar system
This lesson starts the geocentric model of the solar system and showing how this model has a problem with the orbits of planets, which appear to wander across the sky.
Exploring the universe
Despite its name, this lesson is about how we have explored Mars. It starts with some ancient observations, before moving on to describe the satellites and rovers sent to Mars, ending with the Curiosity mission: how it was planned and what it has achieved.
The distance between Earth and Mars
This program showed the orbits of Earth and Mars, noting the date when they line up with the sun (an opposition). It also showed the distance between the planets over time.
I wanted this program to give the correct dates for the oppositions and continue to do so into the future, so I had to make a simple simulation. If the planets had perfectly circular orbits this would have been fine, but because they are slightly elliptical (especially Mars' orbit), they travel around they orbits with a non-constant speed.
Using Euler's forward method is simple but causes the orbit to drift, even when using very small steps. So what I did was use Euler's forward method with 20 small steps, figured out the change in angle this would cause, then apply this change in angle around the ellipse. This way, I could ensure the planet would never leave its ellipse, but could get a sufficiently accurate position that the oppositions were correctly predicted for the 120 years I had data for.
Curiosity rover: mission briefing
This lesson was about the Curiosity mission to mars: why it was going and what the rover could do. The lesson ended with a game based on this video, where students could try to land the rover on Mars. If you don't know how Curiosity was landed on Mars, I recommend this video as it explains just how crazy it was.
As games go, this one is pretty basic: you choose the value of eight parameters, press Start Entry and hope for the best. A few people asked for a game where they could directly control the rover as it lands, but the whole point was that this is impossible due to Mars being 14 light minutes away. I'm surprised that so many people did enjoy it, but then I guess a game is always welcome break from learning.
The game uses a pretty basic physics simulation, but I did a lot of research so it's hopefully quite accurate. I read a lot of papers and even got to ask a NASA engineer some questions, so I could get the masses and tolerances of the various components, such as the heat shield, the parachute and the fuel are correct. I'm sure the game is a lot more forgiving than reality, but otherwise it would have been very difficult.
Overall, I'm pretty pleased with how this game turned out. I'm no designer, but I think it looks pretty good, in a simplistic sort of way. I'm pleased with scorch marks that appear as the landing module enters the atmosphere. At the time, the screen size was limited to 400 x 400 pixels, so I had to fit a lot into a small space, which turned out OK. One thing that could be improved is to give better feedback to why a particular set of parameters failed (other than: you crashed).