# Question Help with orbital math/physics

Discussion in 'Physics' started by mistercow3417, May 12, 2020.

1. ### mistercow3417

Joined:
May 12, 2020
Posts:
3
So I have a scene with a Star and planet it it. I used this equation to calculate force between bodies: F = G * ((M1 * M2) / distance^2). I set G (gravitational constant0 to 0.647f, a bigger number than in rl to test this. It worked fine. When I set G to the real world value of 0.0000000000647f, the planet (lower mass and size than star) would not move but the star would be dragged towards the planet.
Help?
Thanks.

2. ### Edy

Joined:
Jun 3, 2010
Posts:
2,440
Most probably you're using floats beyond their capacity. Floats can store up to 7 significant digits. This means that 0.0000000000647f cannot be stored in a float, and it's effectively zero. The smallest number a float can store is about 0.0000001f.

You should use doubles for your calculations everywhere, including the positions of your bodies. Only convert the resulting positions to floats for actually positioning the objects in the scene.

mistercow3417 likes this.

Joined:
May 12, 2020
Posts:
3
Thanks

4. ### koirat

Joined:
Jul 7, 2012
Posts:
2,031
You got bug somewhere.
Whatever the result of F is, the lighter body should accelerate faster than heavier body.

mistercow3417 likes this.
5. ### mistercow3417

Joined:
May 12, 2020
Posts:
3
Yeah that is what happens when G is a lower number