NASA


7 Mar 2018

Introduction

I worked on Khan Academy's partnership with NASA from July 2013 to its launch on 27th May 2014 (which included the briefest mention by Obama at the Whitehouse science fair). My role was primarily to build all the interactive content, which involved learning a lot of about basic orbital mechanics and ellipses. I also helped with the overall planning of the lessons and some of the exercises (which was mainly done by Brit Cruise).

Surface of Mars

In total I created 23 interactive programs for this tutorial using the Khan Academy computer science environment (Canvas + Javascript + Processing.js).

They include:

  • Interactive diagrams that allow users to click and drag elements to see the effects of their changes.
  • Programs used to generate gifs for animations.
  • Two simple games that allow users to try landing a rover on Mars.

I've written about some of the programs I particularly enjoyed making in a lot more detail below.

Paths of the sun and Mars in the geocentric model.

Lesson breakdown

The NASA tutorial is split into two sections (plus an introduction video), which are in turn split into four lessons each.

Measuring the universe

Measuring the Universe takes a historical perspective on how our understanding of the solar system developed. Many of the programs in this section deal with orbits. I tried to make these as accurate as I reasonably could, which meant having to learn a lot about ellipses.

The section is split into four lessons:

Exploring the universe

Despite its name, Exploring the universe is about how humanity has tried to learn about 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.

Interactive programs

Below I've described some of the programs I made for the NASA lessons in more detail. This probably more for my own interest than another else's.

Curiosity rover: mission briefing

My favourite program from the NASA lessons was this game, in which you have to land the Curiosity rover on Mars. It was based on this video, and also I recommend watching this video which shows just how crazy the landing was.

As games go, this one is pretty basic: you choose the value for eight parameters, press Start Entry and hope for the best. I'm surprised so many people did enjoyed the game and spent so long trying to optimise their landing. But I guess games are always a welcome break from learning.

Screenshot of my simulation of the Curiosity landing craft

The game uses a pretty basic physics simulation, but I did a lot of research so it's hopefully quite accurate. I tried to tweak the simulation to give the same results for parameters such as speed and temperatures at various points. 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.

Curiosity landing with paracute

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).

Landing the Curiosity rover with the sky crane
Are you Santa Claus?
This is like Christmas morning!
Please keep making education software, even if it's only games or simple simulators (perhaps even better). I really haven't had this much fun with science since I was a kid at MOSI in Chicago, and to be fair, I had a pretty good physics professor. :)

The distance between Earth and Mars

Unsurprisingly, many of the programs in the NASA lessons involved orbits. This program shows the orbits of Earth and Mars, recording the date when they line up with the sun (an opposition). It also plots the distance between Earth and Mars over time. I wanted it to give the correct dates for all the oppositions I had data (about 120 years worth). If the planets had perfectly circular orbits this would have been easy, but because they are slightly elliptical (especially Mars' orbit), the speed of their orbits varies over time.

Distance between Mars and the Earth interactive

This meant I had to make a simple simulation. However, using Euler's forward method, which is the simplest method, causes the orbit to drift, even when using very small steps. Even more complex methods drift a fair bit over one hundred years. So instead, I used Euler's forward method with 20 small steps, figured out the change in angle this would cause, then applied this change in angle around the ellipse. This way, I could ensure the planet would never leave the elliptical path I'd set, and I could get the planets' positions around the ellipse accurately enough that the oppositions were correctly predicted for all the values I had.

Features of Mars

This program lets users spin a model of Mars and points to some of its features. I'd not done much with projections before this project, so it was interesting to figure out how to convert a rectilinear image of the surface of Mars into a spherical map.

The hardest part of this program was not the projection, but the fact that I was not (at that time) able to upload images to the Khan Academy coding environment, and the environment prevents you from using external images. So I wrote a Python program to convert the image I had into a 2D array of integers representing the pixel colours. Then my program had to load this uncompressed image data and convert the integers back into R, G, B colour values.

Surface of Mars

Several people have requested that I make it rotate in two dimensions, which should be possible if I can only work out how. Others have also asked to be able to zoom in, which is not possible without improving the resolution of the image, which would slow down the program too much.