开发者

Python framework for visualising/animating particles in cartesian space

开发者 https://www.devze.com 2023-01-27 10:44 出处:网络
I have data representing the position of particles for multiple time steps and need to create an animation showing the movement of these particles.

I have data representing the position of particles for multiple time steps and need to create an animation showing the movement of these particles.

Are there any frameworks or toolkits (ideally Python based) out there does something like this out of the box, or at least something that makes it easy to quickly plot sprites/3d-objects and animate it across multiple time steps?

For the first stage a simple 2D animation is sufficient. However I would like to have the option of extending it further to support 3D and user interaction (changing view, animation control, exporting animation to file, etc).

Just to clarify, I'm not looking to render a complicated scene. Something like the following would do:

Python framework for visualising/animating particles in cartesian space

This particular image is a screenshot of a single frame for a similar 开发者_如何学编程data set.


Pyprocessing is a Python treatment of the processing Java animation library. The processing development environment includes some very nice examples of implementing a particle system.


Houdini by Side Effects Software is an industry-grade 3D animation application with excellent Python bindings, Python expressions and general support. It would be simple to import your data, and Houdini even has a Python shell within the application for tinkering.

After you've imported it you can take advantage of the full range of animation and visualisation tools and the excellent bundled renderer, "Mantra".

There is a free "apprentice" edition with very few restrictions, and various levels of paid licenses.


We've used pyOGRE, which are Python bindings to the OGRE library, which describes itself as:

What Is OGRE? OGRE (Object-Oriented Graphics Rendering Engine) is a scene-oriented, flexible 3D engine written in C++ designed to make it easier and more intuitive for developers to produce applications utilising hardware-accelerated 3D graphics. The class library abstracts all the details of using the underlying system libraries like Direct3D and OpenGL and provides an interface based on world objects and other intuitive classes.


In 2D why don't you just use matplotlib to do scatter plots of the frames from your simulation.

For example

import numpy as np
import matplotlib.pyplot as plt

# Just some sample data but I'm assuming that you 
# can get your data into vectors like this.
x = np.random.randn(100)
y = np.random.randn(100)

plt.figure()
plt.plot(x,y, '.')
plt.savefig('frame0000.png')

You can then make a video from the frames.

As for 3D - you could try matplotlib's mlab or mplot3D. From my experience mlab is a bit trickier to get going. Comment on this post if you need more help with using matplotlib.

http://www.scipy.org/Cookbook/Matplotlib/mplot3D http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/mlab.html


Have a look at PyODE. That will help with the physics part. You're on your own with the graphics.

0

精彩评论

暂无评论...
验证码 换一张
取 消