How can we simulate a box being dropped straight from some height on Earth and graphically show the action in real-time? How will it be different on the Moon? Or on the Sun (assume it can resist the high temperature), or on other planets including dwarf planet like Pluto?

Well, that was my curiousity that led to creation of this simple graphical animation but with proven math behind the visuals. You see, the gravitational forces are different elsewhere than on Earth. I choose a few disparate places in our solar system where the gravitational pulls vary in interesting ways.

We know the gravity on Earth is 9.8 meter/s^2 (squared seconds), whereas on the moon it’s less at 1.62 m/s^2. After a quick research, I also found that on Mars, it’s 3.711 m/s^2, on Jupiter it’s a whopping 24.79 m/s^2, and on the Sun, it’s a mind-boggling 274 m/s^2 (that is if the object survives the heat, which we’ll assume for this simulation). Finally, I’ll throw in our demoted (now dwarf) planet Pluto where it’s a measl7 0.62 m/s^2.

What does this mean to an object dropped from some height? Well, of the places mentioned, only Earth has a measurable air resistance due to its thicker atmosphere. Some of the other places don’t have an atmosphere or it’s so thin that it wouldn’t really matter for my experiment. For that reason, I’ll just leave out the air resistance from the equation. But for offering some knowledge, air resistance is a force that opposes the motion of a falling object, and it depends on the speed, shape, and cross-sectional area

of the object. To include air resistance in our code, we would need to add an air resistance coefficient (k). This coefficient depends on the density of the air, the shape and size of the object, and a drag factor that varies with different objects. We would also need a variable to store the air resistance force, which is proportional to the square of the speed. So, we would subtract this force from the gravity force, and divided by the mass of the object — that way, we can account for how air resistance reduces the acceleration and velocity of the object as it falls. Ok, enough of geek talk, let’s get back to our simulation.

A few things and maths we need to consider on math include: a formula for computing free fall, and time of the trip or fall, we need to convert the distance to screen pixels, and we also need to convert or scale the acceleration into frames. We need to increase the velocity as per the gravity on the location (planet/moon/sun) we are simulating for. To calculate the time (t) it takes for an object to fall from a given height (h) at a given location with a specific gravity (g), first multiply the height with two (2*h), divide it by gravity (g), then take a square root of the thing. This will give us the time in seconds regardless of where you used meter or feet or whatever distance unit…as long as you used the gravity and height in the same distance unit. (So, if the gravity is expressed in meters, the height should be in meters. If in feet, the other parameter should also be in feet.)

On the graphics side, even in this rudimentary rendition, we need to consider a few more things: We need to consider the graphic library that’s light-weight enough not to be bogged down with graphics intricacies, we need to consider the height and width of the window so that we know where to drop FROM and where the “ground” level is, we need to draw in real-time simulating the speed of the drop and refresh the screen for each location, between each location we also want to have a pause so our eyes can see, brain can grasp on fall, before the next, etc. It’ll become clearer in the code.

One of the cleanest ways to implement this and exhibit the phenomenon is to use Turtle library since I’ll be doing this thing in Python. So make it more intuitive, I will also draw a thick line to indicate the ground level where the object will land (so we get a visual reference of the distance). Beyond that, nothing fancy really.

To keep the code modular, I created a couple of custom functions: one for calculating the velocity during the drop and displaying the action visually. It’s called drop(). It takes 2 arguments: the visual object (turtle), and the gravity (g). That’s so I can call the same function with different gravity values to simulate drops on different locations in space.

One more custom function, not required for the visual, is to calculate the free fall time (the trip time) and that’s called time_of_fall() which takes 2 arguments: height and yes, gravity value. The height will be height in meters (since I’m using gravity in meters scale) translated to pixels in the code.

Yet another custom function is draw_horz_line() which draws the thick ground/surface/bottom and takes 4 arguments: the drawing object (turtle), x, y coordinates of where to start drawing the thick line, and the how wide (horizontally) the line should be on screen.

And the final custom function is prep_between_drops() which controls the pause between-drops, and clearing up artifacts on screen from previous graphics, and prepares the screen for new drop visual and animation.

Rest of the functions come from Turtle library for manipulating the visual object, typical math and time libraries (for pause, square root, etc.), and the standard libraries such for displaying on the shell. For comparison and curiosity, I display the height (which of course varies based on your screen/browser) and the time of the free fall based on that specific height correctly after each drop.

**That’s about it. So, how does it look?** See the animation below that shows the drops one-by-one on different planets, moon, and sun, along with each time of fall.

**Where did the object took the longest to reach the ground? Where did the same object dropped from the same height take the least amount of time?**

**Update**: Here’s the embedded full source code + output side-by-side that you can run right in a small window on right here on this page. Click **> **to Run it!

**The entire source code is for anyone to view/download/run/edit from my github repo : https://github.com/flyingsalmon/gravity_planets**

Happy learning!

▛Interested in creating programmable, cool electronic gadgets? Give my newest book on Arduino a try: **Hello Arduino!**

▟