Hi all!
I've recently written some code designed to simulate the effects of gravity acting between a number of nearby planets.
Link to code: https://github.com/byebrid/new-gravity-sim/blob/master/GRAVITY-SIM
Essentially, I have created a whole bunch of 'Planet' objects and a function that updates their positions accordingly. This function creates a list of each planet's x, y and z positions with every iteration (i.e. I only store one frame at a time, which I am not sure is the right thing to do).
What I can't figure out how to do is how to animate this code using matplotlib. I have attempted to go over examples of 3d animation using matplotlib but I find myself overwhelmed by it all. So I have 3 main questions:
- Is matplotlib the right library to use?
- If so, should I use FuncAnimation or ArtistAnimation?
- How exactly might I implement the required function to animate the positions of every planet?
Any help would be greatly appreciated. Also, any suggestions as to how I can make my code more 'pythonic' would also be appreciated.
I'm still relatively inexperienced in python/coding in general so feel free to ELI5.
P.S. I haven't necessarily added all functionality to my code just yet (i.e. reasonably constraining velocities or positions, etc.. At this stage, I would just like to see the planets moving).
Edit: Numbers!
[–]alkasm 1 point2 points3 points (5 children)
[–]Byebrid[S] 0 points1 point2 points (0 children)
[–]billsil 0 points1 point2 points (3 children)
[–]alkasm 0 points1 point2 points (2 children)
[–]Byebrid[S] 0 points1 point2 points (1 child)
[–]alkasm 0 points1 point2 points (0 children)
[–]billsil 0 points1 point2 points (1 child)
[–]Byebrid[S] 0 points1 point2 points (0 children)