This repository contains a Python-based simulation of planets orbiting around the sun using the Pygame library. The simulation models the gravitational interactions between the sun and several planets, allowing you to visualize their orbits.
- Realistic simulation of planetary orbits using Newton's law of universal gravitation.
- Visualization of the planets and their orbits.
- Ability to pause and resume the simulation using the spacebar.
- Display of planet statistics on the screen.
planetSim.py: The main script that runs the planet simulation.tutorial_notebook.py: A script version intended for educational purposes.planetSim.ipynb: A Jupyter notebook version of the simulation for interactive learning.
- python 3.x
- pygame
- ipykernel
-
Clone the repository:
git clone https://github.com/JanFPV/Python-Planet-Simulation-Racobeu.git cd Python-Planet-Simulation-Racobeu -
Install the required packages:
pip install -r requirements.txt
To run the simulation, execute the planetSim.py script:
python planetSim.pyTo interactively explore the simulation, open the planetSim.ipynb notebook in Jupyter:
jupyter notebook planetSim.ipynbThe simulation uses the Planet class to represent each planet. The class includes methods to calculate gravitational forces, update positions, and draw the planets on the screen. The main loop handles the simulation updates and rendering.
- Spacebar: Pause/Resume the simulation.
This project is licensed under the MIT License. See the LICENSE file for details.
This project was developed as part of an educational course at VUAS in Ventspils, Latvia.