You are viewing a single comment's thread from:

RE: Planets | A Multiplayer Planet Gravity Game

in #utopian-io6 years ago

Here is the code: https://github.com/ajayyy/Planets/blob/master/Planets-Base/src/app/ajay/planets/base/PhysicsObject.java#L54

It is the same acceleration equation, but instead of using math to integrate it and find an equation for the position, the acceleration is calculated and then added to the velocity every frame. The velocities are then added to the position every frame.

The velocity is represented as xSpeed and ySpeed.

Sort:  

I know how to simulate it numerically, but how did your trial at a continuous solution look like?

Sadly, these equations have no closed form solution, so I ended up wasting a lot of time on this journey, though I did learn a lot.

As far as I found, there is no continuous solution sadly.

Do you know about the orbit equation? It might be used together with the second kepler law to create a useful equation.

Edit:
Just noticed that you are making gravity towards more then one object at once, so it is indeed not possible :(

Ooh, I never even tried to use that equation, thanks for linking it. Sadly, I don't think this equation will work since it still doesn't find a direction of that velocity, and still requires the positioning (radius), but I will look into using this one. Thanks!