Let's Go to Mars with Martian Lander

This is the beginning of a series of articles where I develop a variation on the classic lunar-lander game themed around the planet Mars. To do this in three dimensions can be rather complicated, so in the spirit of the original arcade game (that I became rather obsessed with, I should admit), I'm going to tackle the simplified two-dimensional problem. I also am going to discount terrain issues, although clearly landing on the very edge of one of the mysterious Martian canals would be more tricky than a flat plain in the Schiaparelli crater.

Oh also, I'm not going to have any graphics at all. This is going to be a game where you enter thrust commands second by second and either shoot off into orbit and land smoothly on the Martian surface or crash into the planet. You want to add graphics? Excellent. But I'm going to leave that as an exercise for you, the reader, as that's pretty far afield for this shell scripting column.

Gravitational Mathematics

I can't begin Martian lander without talking about physics, because it's Newton's laws (they're not just a good idea!) that describe the process of an object coming into the gravitational field of another and being pulled toward its center.

The Newtonian gravitational formula is F = G m1 m2 / r2, and the big idea is that every object in the universe attracts every other object with a force that is proportional to the product of their masses and inversely proportional to the square of the distance between the two objects.

I'm not going to worry about other planets, however, because the gravitational force that far distant objects have on a ship attempting to land on Mars is quite negligible (to say the least). The difference in mass between a planet and a spaceship are enormous too, allowing me to simplify the formula: velocity = gravity * time.

If I drop something out of a stationary helicopter (or off the side of a building), in second 0, it'll be falling at 0 ft/s. After one second, it'll be traveling 32 ft/s, and after ten seconds, it'll be going 320 ft/sec. I'm discounting air resistance, and so on, but this example is regarding landing a spaceship on Mars, so there really isn't much atmosphere to worry about here.

The next question is how far has the object fallen in a specified number of seconds? This is a more complex equation: distance = ( gravity * time**2 ) / 2.

So after those same ten seconds, the object will have fallen (32 * (10**2))/2 = 1600 feet. If I begin the Earthly descent one mile above the surface, that means that without any rockets to slow things down, it'll take just more than 18 seconds to crash.

Mars, however, has a different gravitational force than Earth does. Earth is 32.1 ft/s, while Mars, with only 15% of the mass of our home planet, has a gravity of 12.1 ft/s.


Dave Taylor has been hacking shell scripts for over thirty years. Really. He's the author of the popular "Wicked Cool Shell Scripts" and can be found on Twitter as @DaveTaylor and more generally at www.DaveTaylorOnline.com.