Skip to main content
gamedev.net
🔒 Locked

solar system gravity

Started by Nightwalk 6 replies 2.3k views
Original Post
Nightwalk
Nightwalk
Hi i am trying to make a simple solar system simulator. I want to have the sun and the 9 planets revolving around it with gravity. Like this but with 9 planets: but i am not sure how to make the gravity work and how do i set up the correct distances and masses etc ? What are the formulas?? Nightwalk
Dmytry
Dmytry
Get some physics textbook.
Anyway.
Gravitation force between masses:
F=m1*m2*G*(P1-P2)*((P1-P2) Dot (P1-P2))-3/2
where P1 it's planet 1's position, P2 it's planet2 position.
It gives force acting on planet2. Force on planet1 is the same but negated.

If you want it to simply look like solarsystem you can just make planets fly on predefined elliptical orbits...

and as about planetary data, try a websearch for [planet name you want] nasa
and you'll get to nasa's "homepage" of that planet where all data is avaliable.
Motorherp
Motorherp
For stable elliptical orbits the line connecting the star to the planet sweeps out equal areas in equal time intervals. If you calculate this rate of area swept you can calculate the position and velocity of the planet at any time without having to resort to using forces and dynamics. Can't remember the equations but Google for Keplers laws and you'll no doubt find something.
[size="1"] [size="4"]:: SHMUP-DEV ::
dodecahedron
dodecahedron
You're going to need to know the eccentricity of the orbits. That means how much they deviate from circular orbits, so if e=1 you have a perfect circle, but if it is something like e=0.8, then I think it works like this: 0.8 is the ratio of the major axis to the minor axis. You can find this and other useful data from JPL's solar system dynamics group, ssd.jpl.nasa.gov, the Horizon's system.


subflood
subflood
Take a look at this project http://www.shatters.net/celestia/

It's open source so you can check out their code.
Kurioes
Kurioes
Don't try to simulate the solar system using physics; most likely it'll become unstable (meaning planets are going to steal each other's energy; one being sling shot away while the other one gets closer to the sun).

Having said that it's a lot of fun to simulate it anyway but don't count on immediate success.
jperalta
jperalta
Quote:
Original post by Kurioes
Don't try to simulate the solar system using physics; most likely it'll become unstable (meaning planets are going to steal each other's energy; one being sling shot away while the other one gets closer to the sun).

Having said that it's a lot of fun to simulate it anyway but don't count on immediate success.


That's not true. You can simulate the system having each planet only be affected by the strongest gravitational force. This is a fairly precise model and does not have that problem. Basically, you solve Kepler's Laws and the gravity equations using only a two-body system instead of a many-body system. This works because the gravitational force between the planets is trivial with respect to the gravitational force between the sun and a planet.
TheWanderer
TheWanderer
Quote:
Original post by jperalta
That's not true. You can simulate the system having each planet only be affected by the strongest gravitational force. This is a fairly precise model and does not have that problem. Basically, you solve Kepler's Laws and the gravity equations using only a two-body system instead of a many-body system.


I agree with you. I've actually done this model myself and have been able to create various semi-stable systems (they sometimes fall apart after an hour running; I think it might have to do with floating point precision).

Quote:
Original post by jperalta
This works because the gravitational force between the planets is trivial with respect to the gravitational force between the sun and a planet.


One thing that gravitation takes into account is mass, and the mass of the sun is so great when compared to the planets that their gravitational pull is insignificant. By taking mass into account in your model, you might be able to produce a stable system even if you count the effect of other planet's gravitational pull.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.