stfc-workexp / solar_simulation

a simulation of the solar system using turtle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

solar_simulation

a simulation of the solar system using turtle This project uses classes to define properties to objects. Using an (x,y) grid and giving x and y velocities, the program will give each planet a set of attributes. With the fundamental laws of gravity and physics coded in through equations, you can accurately simulate each planet's orbit path, or if you would rather see more theoretical possiblities, perhaps you would like to add in multiple 'suns' to see how the planets react (I have commented out segments of code that can act as such). You can add planetary bodies by simply adding a small amount of information without the need for entirly new code and structuring. These can be found in thte function 'main' The program will first import both 'math' and 'turtle', define all the functions in the program and also set up the class. From here, 'main' will take place, assigning each body its individual properties, and adding each of these to the list 'bodies'. The funnction 'loop' then begins, which is self explanatory. This is also where turtle functions start taking action, the step counter begins, and 'time' is defined. Everything loops the amount of times as the amount of bodies you have. 'update_info' now begins, using the variables assigned to the individual bodies, the pythagoras theorem and trigonometery to calculate new values, which are added to the values from all the planets to find a total.

About

a simulation of the solar system using turtle


Languages

Language:Python 100.0%