- #1
- 959
- 0
I'm attempting to make a program which simulates the gravity of bodies in space. However, I've run into a problem:
The program takes the acceleration/speed/position at a certain time and calculates the new values a (small value of time) later. However, this doesn't work because when two masses get VERY close together:
-The program ees that they are VERY close and gives them a MASSIVE acceleration.
-This results in the planets ending up far away from each other in the next frame.
-Energy isn't conserved and the whole thing is useless.
I was just wondering if anyone had the formula for average gravity over a distance over a period of time. I can make a basic formula for average acceleration assuming the planet continues moving the same speed through the distance. However, the planet will change velocity, so it still won't be accurate at very close distances.
The program takes the acceleration/speed/position at a certain time and calculates the new values a (small value of time) later. However, this doesn't work because when two masses get VERY close together:
-The program ees that they are VERY close and gives them a MASSIVE acceleration.
-This results in the planets ending up far away from each other in the next frame.
-Energy isn't conserved and the whole thing is useless.
I was just wondering if anyone had the formula for average gravity over a distance over a period of time. I can make a basic formula for average acceleration assuming the planet continues moving the same speed through the distance. However, the planet will change velocity, so it still won't be accurate at very close distances.