Newtonian Orbit

Instructions

Use Newtonian gravity F = G M m / r^2 to calculate acceleration and velocity to update star's and planet's position.

Different orbits can be obtained by adjusting velocties (vx_*, vy_*) of the star and the planet. You should click on See Inside to move the star and the planet around.

Example settings at these YouTube videos:
https://youtu.be/wTRE0hCD7Yo (Star is 1000 times the mass of planet)
https://youtu.be/sxBFtk5zUJ8 (Star and planet have about the same mass)
https://youtu.be/tDOIaxLAdCk (Using star for gravity assist)

Notes and Credits

Calculate the gravitational force between a star and a planet which depends on star's mass, planet's mass, and the distance between the star and the planet.

Calculate acceleration of star and planet which is the gravitational force divided by mass

Use the acceleration to update the velocity of star and planet.

Use the velocity to update the positions of star and planet.

The above calculations involve solving differential equations. We solve them numerically using Euler method (https://en.wikipedia.org/wiki/Euler_method) or midpoint method (https://en.wikipedia.org/wiki/Midpoint_method) for better accuracy.

Shared: 28 May 2018 Modified: 1 Jun 2018

More projects by psaipetc