Instantly share code, notes, and snippets.

# CodeDotJS/solar_system.py

Last active February 3, 2023 17:31
Solar System using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

### RMuskovets commented Aug 1, 2018

okay, but when i ran it, planets werent normally running by their orbit.

### gutzbenj commented Jan 26, 2020

Ofcourse not, you should get the information for the starting velocity first. Then you can add on this velocity future movements by gravitational forces.

### James-Cuadra commented Apr 19, 2020

Hi, I am trying to recreate this for fun but I have an issue and it would be great if you could help.
How did you determine the way the planets will move depending on their mass and distance to the Sun? i.e. what equations and what data you needed to know about each planet..
Thanks

### gutzbenj commented Apr 23, 2020 • edited

@James74351595 Let's say you have a timeseries of positions of the planets. Then following steps should help you:

• Step 1: Select starting point 0 with a preceeding -1
• Step 2: From those two steps calculate the starting velocity of the planets by dividing the subtraction the two positions by the time that has passed between the two points
• Step 3: Start iterating through the planets to calculate the gravitational forces of every other body in the system on that one body
• Step 4: Add the resulting vector of forces on the current velocity of the body
• Step 5: -> Step 2

### greenvi commented Jun 9, 2022

wow, nice.... Im impressed.

### ajmal-13 commented Jul 18, 2022

I begin to learn python programming I attend my first session today and I get to know ur page in Instagram and this reels was amazing..It improved my interest in learning python ..