Monday, March 18, 2013

VPython - Python plus 3D graphics


By Vasudev Ram

VPython 'is the Python programming language plus a 3D graphics module called "visual" originated by David Scherer in 2000. VPython makes it easy to create navigable 3D displays and animations, even for those with limited programming experience. Because it is based on Python, it also has much to offer for experienced programmers and researchers.' - from the VPython site.

I had come across VPython quite a few years ago, and tried it out a bit at the time. I saw it again today via a chain of links, and was interested to see that it has been updated for recent Python versions. I downloaded and installed the VPython version for Python 2.7.3 and tried out the bouncing ball VPython example. It worked fine.

A couple of interesting points about VPython:

- it has what seems to be a modified version of the Python GUI shell, IDLE, called VIDLE, that works like IDLE, and when you enter and run a VPython program, it displays the 3D graphics output in one of the VIDLE windows. I entered and ran the bouncing ball example using VIDLE.

- going by the bouncing ball example, VPython seems to use some form of partially declarative, rather than procedural code, for parts of what it does, since the example does not actually have any code to update the graphics on the screen - it just 'has computations to update the position of the ball and check whether it hits the floor. The 3D animation is a side effect of these computations.'

Update:

The latest version of VPython has been modified to use wxPython:

https://github.com/BruceSherwood/vpython-wx#readme

- Vasudev Ram - Dancing Bison Enterprises



No comments: