r/M5Stack • u/cubic9com • Mar 22 '25
a gravity simulator of planetary system for M5Stack Core 2
I made a gravity simulator of planetary system for M5Stack Core 2 . Try it out and let me know how it goes! https://github.com/cubic9com/m5core2_gravsim
2
u/cubic9com Mar 22 '25
Thanks for your feedback, everyone!
Here is the code for M5Burner !
Code: UwE1Ekq5yMOozHfk
Usage
Register an M5Stack Community account if you haven't already.
Launch the M5Burner.
Click
USER CUSTOMin the lower left corner.Log in to the M5Stack Community.
Click the
Share Burnbutton.Enter
UwE1Ekq5yMOozHfkin theShare Codefield.Click the lightning icon.
2
u/Virtosaurus Mar 24 '25
I've heard that the three-body problem is not even solved in a general way, how does it simulate so many planets moving under the influence of mutual gravity?
→ More replies (1)1
u/cubic9com Mar 24 '25
Thank you for your interest. My mathematical knowledge is limited, and my English writing skills are also poor, so it's difficult to explain, but I'll give it a try. To put the conclusion first, I am simply applying the law of universal gravitation. The three-body problem refers to the motion of three objects interacting through gravitational forces. You know, there is no general analytical solution (a single formula that works for all initial conditions) using Newton's equations of motion. This is because the system exhibits chaotic behavior, where small differences in initial conditions lead to significant changes in trajectories. Even though a general solution cannot be found, numerical methods allow us to approximate the trajectory for specific initial conditions. I used the Euler method. Although this method has large errors and is not suitable for precise simulations, it is simple to implement and sufficient for just having fun. For more details, please refer to lines 48-87 of PhysicsEngine.cpp.
1
7
u/BuyOk1427 Mar 22 '25
That's really cool! Well done
If I had the hardware I'd definitely have a play with that
6
1
3
3
u/SarahC Mar 22 '25
OP - I'm wondering - would you ever upload Arduino IDE/PlatformIO and M5Burner versions of your code?
Lots of people out there with those different IDE's, or find them too scary.
It's a PITA, but I've done it in the past occasionally. :)
3
2
2
1
1
10
u/Rare_agency101 Mar 22 '25
please put it on m5 burner!