python 3D可视化和图形
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18026134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
python 3D visualization and graphics
提问by CodeKingPlusPlus
I am looking for Python compatible 3D graphics. Mostly I would like to be able to draw lines and view them in 3D. I literally have no experience in this area and am looking for knowledge and tutorials.
我正在寻找与 Python 兼容的 3D 图形。大多数情况下,我希望能够绘制线条并以 3D 方式查看它们。我真的没有这方面的经验,正在寻找知识和教程。
I learn programming best by experimentation. So which packages do I need to do 3-D graphics? I really enjoy using emacs, so if you have those suggestions as well that would be awesome!
我通过实验学习编程最好。那么我需要哪些包来做 3-D 图形呢?我真的很喜欢使用 emacs,所以如果你也有这些建议,那就太棒了!
In summary:
总之:
- Which packages do I need for 3D graphics in python.
- Note that I use Ubuntu 12.04 LTS and emacs 24.3
- python 中的 3D 图形需要哪些包。
- 请注意,我使用 Ubuntu 12.04 LTS 和 emacs 24.3
采纳答案by Justin Meiners
EDIT
编辑
My answer below is for those who are interested in realtimegraphics. If you just need to draw a 3D graph and periodically update it, something like gnuplotmay be more appropriate.
我下面的回答是为那些对实时图形感兴趣的人准备的。如果你只需要绘制一个 3D 图形并定期更新它,像gnuplot这样的东西可能更合适。
Also see Tom's answer below.
另请参阅下面汤姆的回答。
ORIGINAL
原来的
The most common way to integrate realtime 3D graphics is using the OpenGLlibrary. OpenGL and realtime graphics is a big topic, but focusing on something like drawing 3D lines should not be too difficult. Bindings exist for python http://pyopengl.sourceforge.net/
集成实时 3D 图形的最常见方法是使用OpenGL库。OpenGL 和实时图形是一个很大的话题,但专注于绘制 3D 线条之类的东西应该不会太难。python 存在绑定http://pyopengl.sourceforge.net/
GLUT- is probably the best for providing X platform windowing and context setup, and is included in the mentioned bindings.
GLUT- 可能是提供 X 平台窗口和上下文设置的最佳选择,并且包含在上述绑定中。
OpenGL- there are several versions, for your application, immediate mode, legacy, is probably acceptable.
OpenGL- 有几个版本,对于您的应用程序,立即模式,遗留,可能是可以接受的。
Here are some links for learning - Don't feel obligated to read them all - pick the topics that are relevant to you.
这里有一些学习链接 - 不要觉得有义务阅读它们 - 选择与您相关的主题。
回答by tom10
The easiest way for 3D visualization in Python is VPython.
在 Python 中进行 3D 可视化的最简单方法是VPython。
For example, to draw a curve in the shape of a square, it's just:
例如,要绘制一条正方形的曲线,只需:
square = curve(pos=[(0,0),(0,1),(1,1),(1,0),(0,0)])
This is vastly easier than MayaVI, VTK, OpenGL, etc.
这比 MayaVI、VTK、OpenGL 等要容易得多。
Another easy option is matplotlib's 3D graphics. It's better on the quantitative details, but not as simple, fast, and interactive for the 3D part.
另一个简单的选择是 matplotlib 的 3D 图形。它在定量细节上更好,但不如 3D 部分简单、快速和交互。