Programming the Heliocentric System in Python
By Roy Stracovsky
To learn about the Scientific Revolution, I decided to recreate the current heliocentric system. With that in mind, I thought of how it should be made. At first, I thought that I could make it using a crude foam ball and wire system, but the planets couldn't move, and if I figured how to make them move, they would revolve around the sun in circles, and this is incorrect. I looked for other ideas, and thought about what I also wanted to learn, while learning about the heliocentric system, and it hit me, I should program the system. I decided to use Python, a language that is taught in the upper-school.
Before I go into how I programmed the system, I would like to explain when it was discovered. Previous to the system, there was a different system. This system was was the geocentric system and it displayed, that the sun and moon and planets revolve around the earth. This was created by Ptolemy.
As you can see, saturn, mars, jupiter, venus, and mercury, seem to be revolving in circles, around an invisible point, this is very odd, but back then, this was the way. In time, a scientist called Copernicus thought differently. He believed that all the planets revolved in a circular orbit around the sun. This is close to our current solar system, but this was slightly incorrect. He was missing the fact that planets revolve in ellipses. Later, Kepler, another scientist, discovered this fact through some data.
Now we can get to the program. First, we need to install Andrew Miller's Graphics Library to make the animations. Here is the webpage where you can download it.
Next we can make a new document in Python Idle. This is where we put our code.
Now we need to add the animation framework code. This is necessary for the library. It is the thing that runs the animation.
Next, we can make variables. The variables are only for mercury because I only want to test a olanet first, then add the others.
Now we need to define a function that takes a planets time it takes to orbit the sun, speed that it does that to, which place it is in in the system, and the size of the planet.
First you need to find the base size, and add it to increment of x times the orbit to the power of 1.1. Take all of this and divide it by two, and you have horizontal radius. To make the vertical radius, do the same but using the incrY instead.
To make the x position for the planet, add the horizontal radius to the cosine of the remainder of time multiplied by the speed, and 360. We will call this "degree".
For the y position, we take the radiusY, and multiply it by the sine of degree.
Now, we draw the circle, so when the function is applied, we want to make the circle. We put in the x coordinate and the y coordinate, and we put in the radius.
Now, for future planning, if the planet orbit is saturn, we want to add a ring on top of the planet.
Next, we add another function. This function draws the solar system. First, we draw a yellow circle, or the sun.
After that, we make a loop that starts at one and goes nine spaces, or to ten. We make a horizontal diameter that takes the base size and adds it to the product of incrX and the power of the time that is looped to the 1.1th. We do this to make the vertical diameter too. Now we draw an ellipse at the origin with the horizontal and vertical diameters.
Finally, we need to draw the things. We need to reset a matrix, make the origin in the center of the screen, draw the system in the current time, a variable that we create, and add one to the time.
Now for the final with mercury, you need to take away the orbit ellipse drawn, and fix up some bugs like the translate by adding 200.
Now you can add the other planets!
Nowadays, we take it for granted that the orbits are ellipses, but in reality, it is so hard to program and hard to discover. By doing this, this has been a quadruple learning situation through math, science, history, and computer science! I will forever have this seared in my brain.
Before I go into how I programmed the system, I would like to explain when it was discovered. Previous to the system, there was a different system. This system was was the geocentric system and it displayed, that the sun and moon and planets revolve around the earth. This was created by Ptolemy.
As you can see, saturn, mars, jupiter, venus, and mercury, seem to be revolving in circles, around an invisible point, this is very odd, but back then, this was the way. In time, a scientist called Copernicus thought differently. He believed that all the planets revolved in a circular orbit around the sun. This is close to our current solar system, but this was slightly incorrect. He was missing the fact that planets revolve in ellipses. Later, Kepler, another scientist, discovered this fact through some data.
Now we can get to the program. First, we need to install Andrew Miller's Graphics Library to make the animations. Here is the webpage where you can download it.
Next we can make a new document in Python Idle. This is where we put our code.
Now we need to add the animation framework code. This is necessary for the library. It is the thing that runs the animation.
Next, we can make variables. The variables are only for mercury because I only want to test a olanet first, then add the others.
Now we need to define a function that takes a planets time it takes to orbit the sun, speed that it does that to, which place it is in in the system, and the size of the planet.
First you need to find the base size, and add it to increment of x times the orbit to the power of 1.1. Take all of this and divide it by two, and you have horizontal radius. To make the vertical radius, do the same but using the incrY instead.
To make the x position for the planet, add the horizontal radius to the cosine of the remainder of time multiplied by the speed, and 360. We will call this "degree".
For the y position, we take the radiusY, and multiply it by the sine of degree.
Now, we draw the circle, so when the function is applied, we want to make the circle. We put in the x coordinate and the y coordinate, and we put in the radius.
Now, for future planning, if the planet orbit is saturn, we want to add a ring on top of the planet.
Next, we add another function. This function draws the solar system. First, we draw a yellow circle, or the sun.
After that, we make a loop that starts at one and goes nine spaces, or to ten. We make a horizontal diameter that takes the base size and adds it to the product of incrX and the power of the time that is looped to the 1.1th. We do this to make the vertical diameter too. Now we draw an ellipse at the origin with the horizontal and vertical diameters.
Finally, we need to draw the things. We need to reset a matrix, make the origin in the center of the screen, draw the system in the current time, a variable that we create, and add one to the time.
Now for the final with mercury, you need to take away the orbit ellipse drawn, and fix up some bugs like the translate by adding 200.
Nowadays, we take it for granted that the orbits are ellipses, but in reality, it is so hard to program and hard to discover. By doing this, this has been a quadruple learning situation through math, science, history, and computer science! I will forever have this seared in my brain.