Help with orbital math/physics

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.
Thanks. :)

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.

1 Like


You got bug somewhere.
Whatever the result of F is, the lighter body should accelerate faster than heavier body.

1 Like

Yeah that is what happens when G is a lower number