some questions #3
-
Dear rafael, I have some questions about the program. I want to know how to set the number of the particles and let the simulation auto-run without pulling the time line below the figure. I just mean how to make it like your examples of the video on youtube. Thanks a lot. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For setting a new particle just create the particle with Particle() constructor takes two arguments, the first is the initial position of the particle and the second is the initial velocity.
For my youtube video I plot the simulation frame by frame and the I merged all frames in to a video using ffmpeg An alternative for doing directly in matplotlib is using matplotlib.animation.ArtistAnimation, but unless you want make a video to post it somewhere for testing it's better an slider because it allows seeing easily any instant of the simulation. For the frame by frame approach remplace the matplotlib code in the end of N-body simulation.py with this:
Sorry for the delay in replying, I missed the notification. |
Beta Was this translation helpful? Give feedback.
For setting a new particle just create the particle with
Particle()
constructor and add to the current list of particlespar
with append() method.Particle() constructor takes two arguments, the first is the initial position of the particle and the second is the initial velocity.
For my youtube video I plot the simulation frame by frame and the I merged all frames in to a video using ffmpeg
An alternative for doing directly in matplotlib is using matplotlib.animation.ArtistAnimation,…