Calculating orbits of moons, when both the planet and star are involved.

In summary, you are experiencing the pain of the three body problem. There is no analytical solution. Can you get a planet to move in a straight line at a constant speed without leaving it's moon behind? It may be that your planets are going too fast in their orbits (or that you have a dud algorithm) for the moons to keep up: have you compared the speeds with the escape velocities? Or it could be that the star's gravity is too strong and it is just ripping the moons away to itself. Have you set up your model so the star's gravity also affects the moon?I've been working on a java app which shows the orbits of satellites around a gravity source.
  • #1
sydan
5
0
Hi there!
I'm developing a game that involves simulating a star system. I'm using the Unity engine and its physics engine. I've got gravity working perfect.

I've also developed an algorithm that works out how much force you would need to apply to a body to start it orbiting around another (stationary) body. It works perfectly; I've made a series of moons orbit a planet without deviation for an unlimited length of time.
The problem I now have is that when I set the planet up to orbit around the star, the moons don't stay with it, they just get left behind.

To try and overcome this problem I made my orbit calculating algorithm recursive so that each moon first works out the force it needs to start orbiting the planet, and then adds that to the force it would need to orbit the sun to try and keep it with the planet.
This didn't work, the moons don't orbit the planet as far as I can tell. All the moons and the planet start orbiting the star and gradually spread out across the orbit so that some moons are ahead and some are behind.

Just so its clear these are perfectly circular orbits. I was just wondering if anybody had any idea how to make the maths work for this? I'm a bit stumped... I can't think how to do it...
Matt
 
Astronomy news on Phys.org
  • #2
Welcome to PF.
sydan said:
I'm developing a game that involves simulating a star system. I'm using the Unity engine and its physics engine. I've got gravity working perfect.
presumably not perfect... or you wouldn't be here.
I've also developed an algorithm that works out how much force you would need to apply to a body to start it orbiting around another (stationary) body. It works perfectly; I've made a series of moons orbit a planet without deviation for an unlimited length of time.
presumably not unlimited but ho hum...
The problem I now have is that when I set the planet up to orbit around the star, the moons don't stay with it, they just get left behind.
... does the moon end up falling into the star or flying off the screen?
To try and overcome this problem I made my orbit calculating algorithm recursive so that each moon first works out the force it needs to start orbiting the planet, and then adds that to the force it would need to orbit the sun to try and keep it with the planet.
This didn't work, the moons don't orbit the planet as far as I can tell. All the moons and the planet start orbiting the star and gradually spread out across the orbit so that some moons are ahead and some are behind.
Yes, that would be about right.

Just so its clear these are perfectly circular orbits. I was just wondering if anybody had any idea how to make the maths work for this? I'm a bit stumped... I can't think how to do it... Matt
You are experiencing the pain of the three body problem. There is no analytical solution.

Can you get a planet to move in a straight line at a constant speed without leaving it's moon behind? It may be that your planets are going too fast in their orbits (or that you have a dud algorithm ... ) for the moons to keep up: have you compared the speeds with the escape velocities? Or it could be that the star's gravity is too strong and it is just ripping the moons away to itself.

Have you set up your model so the star's gravity also affects the moon?
 
  • #3
I've been working on a java app which shows the orbits of satellites around a gravity source. I might have the smallest of tips concerning the moon, planet and star problem.

I was able to take a satellite flying at a certain velocity near a gravity source at a certain distance and moving a certain angle and determine from these whether a hyperbola or ellipse would form.
The hairy part was incorporating the fact that the the gravity source was *also* moving.

I had to take the velocity vector of the planet (the earth) and subtract it from the velocity vector of the moon (luna) and then (!) calculate the orbit of luna. This would make the Earth look like it was standing still, and the whole math problem woud be easier. Then I added the vector of the Earth back to both and continued with the animation. It caused luna to rotate around the Earth but of course from the perspective of the star, watching the Earth move as well, the path traced out by luna was a kind of spiral.

If your luna gets left behind perhaps its kinetic energy, rotational speed, is not high enough to stay "stuck" to the earth.

I don't know what a Unity engine is, but I hope the vector tip helps.
 
  • #4
presumably not perfect... or you wouldn't be here. [...] presumably not unlimited but ho hum...
It's pretty close! I put time up to 100x and left it for several hours and there was no deviation in 2 body orbits.

... does the moon end up falling into the star or flying off the screen?
Fall towards the star..

You are experiencing the pain of the three body problem. There is no analytical solution.

Can you get a planet to move in a straight line at a constant speed without leaving it's moon behind? It may be that your planets are going too fast in their orbits (or that you have a dud algorithm ... ) for the moons to keep up: have you compared the speeds with the escape velocities? Or it could be that the star's gravity is too strong and it is just ripping the moons away to itself.

Have you set up your model so the star's gravity also affects the moon?

I set the planet up to move in a straight line... If the moons are not given the same velocity they just get left behind. If they are given the same velocity they don't orbit properly, they lose their orbits very quickly (after about 2-3 revolutions), some of them spin off, others fall in towards the planet.

The algorithm works perfectly for stationary bodies... I can't see how I should edit it for moving ones.

I'll set about comparing velocities. The star may be ripping them off, but I'm not certain the star is the problem.

Has anyone solved this problem before?
 
  • #5
Rapidrain said:
I've been working on a java app which shows the orbits of satellites around a gravity source. I might have the smallest of tips concerning the moon, planet and star problem.
Awesome!

I was able to take a satellite flying at a certain velocity near a gravity source at a certain distance and moving a certain angle and determine from these whether a hyperbola or ellipse would form.
The hairy part was incorporating the fact that the the gravity source was *also* moving.
Sounds pretty close to my problem.

I had to take the velocity vector of the planet (the earth) and subtract it from the velocity vector of the moon (luna) and then (!) calculate the orbit of luna. This would make the Earth look like it was standing still, and the whole math problem woud be easier. Then I added the vector of the Earth back to both and continued with the animation. It caused luna to rotate around the Earth but of course from the perspective of the star, watching the Earth move as well, the path traced out by luna was a kind of spiral.
This sounds like a reasonable solution. I'd have to really thrash it out, but I feel you're close to the correct answer. Thanks for the hint :)

If your luna gets left behind perhaps its kinetic energy, rotational speed, is not high enough to stay "stuck" to the earth.

I don't know what a Unity engine is, but I hope the vector tip helps.
I'm not too experienced with how kinetic energy will affect the situation. What's the maths for it?

The unity engine is just a game that supplies a preconstructed physics engine for you, it covers basic mass, forces, friction, torque, etc. If you want it to be more complex you have to add to it.

Thank you for the reply! I'll get back as soon as I've tested further.
 
  • #6
Did some more tests. I found that moons orbit planets that are moving with consistent velocity completely fine if there's only one or two moons involved. Lots of moons cause too much disturbance for orbits to be maintained.

Moons and planets rotating around a sun doesn't work at all, even if there's only one moon. So perhaps the gravity of the sun is stripping the moons off.
 
  • #7
I'd have to really thrash it out,

Well said. This is what I've been thinking for the past 18 months.

I'm not too experienced with how kinetic energy will affect the situation. What's the maths for it?

There is very much math involved in the orbit calculations. First and foremost : conservation of energy. KE + PE is always the same.

KE = v*v/2 and PE = -GM/d

So you have two equations but dx/dt (change of distance over time) is v and x is d (distance) so you have an integral to solve :yuck: which I gave up on quite soon. You see, initially I thought I could find a function of distance in a two dimensional space = f(t). The stuff I just mentioned however gets you only a time = f(distance) in a one dimensional setting and that is all.

Look up the vis-viva forumula from Isaac Newton and study the geometry of an ellipse. Look at the dimensions of the ellipse and the major axis, minor axis, eccentricity and position of the focus points. Find out the ratio of the velocities between the periapsis and apoapsis. Find out how Kepler calculated the orbital period. Orbital mechanics are really interesting.

I don't want to take the fun out of it from you so I won't bore you with all the details of my iteration loops etc. Here's a screen shot of what I've got so far.

With my little project I just recently had to solve a a cubic polynomial with the code. That was cool. All kinds of strange things have to get solved. I bet if I continue with it I'll certainly find a Higgs Boson lying somewhere in it by next spring.
 

Attachments

  • SpaceFlight 110.jpg
    SpaceFlight 110.jpg
    34.4 KB · Views: 647
  • #8
The motions are chaotic, so any step-wise integration based on a set of initial conditions will tend to give you errors that grow over time. I can guarantee you you don't have gravity working "perfectly"!

Try making the mass of the moons extremely small compared to the other two. This is equivalent to the "restricted" three body problem and it should lead to better stability in the simulations. The moon will still orbit semi-realistically because it's still a free-falling mass, the difference will be that the motions of the sun/planet will be independent of the position of the moon.

Also if you have any control over the physics it is useful to plot the total energy of the system as a function of time because this will give a barometer of the inaccuracy of the simulation. If it varied by over 10%, for example, you know things are getting more and more divergent from reality.
 
  • #9
MikeyW said:
The motions are chaotic, so any step-wise integration based on a set of initial conditions will tend to give you errors that grow over time. I can guarantee you you don't have gravity working "perfectly"!

Try making the mass of the moons extremely small compared to the other two. This is equivalent to the "restricted" three body problem and it should lead to better stability in the simulations. The moon will still orbit semi-realistically because it's still a free-falling mass, the difference will be that the motions of the sun/planet will be independent of the position of the moon.

Also if you have any control over the physics it is useful to plot the total energy of the system as a function of time because this will give a barometer of the inaccuracy of the simulation. If it varied by over 10%, for example, you know things are getting more and more divergent from reality.

Hi, thanks for the comment. I haven't had time to test much but I've found that the total energy of the system gradually decreases. This sort of makes sense as there's no such thing as heat or sound in the simulation so collisions are approximated. But generally I can't tell if the decrease is too much yet.

To the general problem... I might have to cheat and fix it using some sort of cover up. I can't think how to get the whole thing to work otherwise.
 

1. How do you calculate the orbit of a moon when both the planet and star are involved?

Calculating the orbit of a moon when both the planet and star are involved requires knowledge of the masses and distances of all three bodies. This information can then be used to apply Kepler's laws of planetary motion to determine the orbit of the moon around the planet, while taking into account the gravitational pull of the star as well.

2. What is the importance of calculating orbits of moons in relation to the planet and star?

Calculating the orbits of moons in relation to the planet and star allows scientists to better understand the dynamics of the entire system. This information can also be used to predict future positions of the moons, which is important for space exploration and navigation.

3. How do you account for the gravitational pull of the star when calculating the orbit of a moon around a planet?

To account for the gravitational pull of the star, scientists use the concept of barycenter, which is the center of mass of the entire system. The orbits of both the planet and moon are affected by the gravitational pull of the star, so their combined center of mass must be calculated and used in the equations for orbit determination.

4. Can the orbit of a moon change over time when both the planet and star are involved?

Yes, the orbit of a moon can change over time due to various factors such as the gravitational pull of other nearby planets or bodies, tidal forces, and even the mass and composition of the moon itself. Calculations must be regularly updated to account for these changes.

5. How accurate are the calculations for determining the orbit of a moon when both the planet and star are involved?

The accuracy of these calculations depends on the accuracy of the data used, such as the masses and distances of the bodies involved. With precise measurements and advanced mathematical models, these calculations can be very accurate. However, there may still be slight discrepancies due to unpredictable factors such as gravitational perturbations from other bodies.

Similar threads

  • Sci-Fi Writing and World Building
Replies
1
Views
871
  • Astronomy and Astrophysics
Replies
11
Views
2K
Replies
17
Views
2K
  • Astronomy and Astrophysics
Replies
1
Views
1K
  • Astronomy and Astrophysics
Replies
2
Views
2K
  • Astronomy and Astrophysics
Replies
4
Views
1K
  • Astronomy and Astrophysics
Replies
7
Views
2K
  • Astronomy and Astrophysics
Replies
12
Views
3K
Replies
4
Views
712
  • Astronomy and Astrophysics
Replies
2
Views
1K
Back
Top