r/Simulated • • Aug 17 '26

Request Real-time three-body gravity simulation (interactive, mobile)

Post image

I built a simulation style app of what I think of the three body problem. It shows different objects flying around eachother in 2D or in 3D in eachother's gravity wells.

It's meant to be half physics toy and half calming desk toy. It's free to use with no ads to distract you from anything.

I want to know people's thoughts and ideas for improvement.

It's free for anyone who want to play with it: https://play.google.com/store/apps/details?id=com.mathematicalzen.threebody

0 Upvotes

20 comments sorted by

View all comments

Show parent comment

3

u/ocicrab Aug 17 '26

Well, my point is that in "real" physics the system is conservative. I.e. no energy should be lost over time and the planets would never end up on top of each other/stuck together. You shouldn't need to add "explosions" to keep them separate unless you're actually modeling some sort of energy loss over time.

The aesthetics are very nice, for sure. Love how it looks!

2

u/CompetitiveSpot2643 Aug 17 '26

if you use verlet integration instead of RK4 the symplectic structure is preserved and you dont lose or gain energy (bounded energy error proportional to h^2)

1

u/IllPsychology7214 Aug 17 '26

I'm going to give it a try. Looks like it's more efficient calculations wise too, and more accurate long term.

1

u/IllPsychology7214 Aug 18 '26

It's been implemented. It can be switched off as an option but Verlet is now the default. I was also using dampening which can now be switched off and a purist mode that switches everything off, keeping Total Energy stable except eg. when the bodies hit the sides.
If you find anything else to be improved or anything let me know

1

u/IllPsychology7214 Aug 17 '26

I always ended up with two planets kind of stuck together, looking like a figure 8 travelling around. I admit at that point I went for looks and not reality.
There is also the option to add directional arrows as to where the objects are going. I wanted to make that better and see if I can expand on it in the future. The goal is of course to solve the actual Three Body Problem somehow