vpython version 5
The other day I discovered that the folks working on VPython have been very busy over the last couple of years. I had given up on VPython because the Mac distribution was so difficult to use. It required the X windows server and one point and lots of other extra junk at other times. But now things are easy! There is a great installer package and it just works.
For those of you who have not heard of VPython before it is a 3D graphics module called visual built on top of Python and OpenGL. You can do a lot of nice 3D graphics very simply with VPython. Its great for education in math and physics and introductory computer science.
So as an experiment I built a turtle graphics module on top of VPython. I use turtle graphics a lot in teaching but the TKinter turtles all suffer from some event loop problems when you use them with IDLE. VPython does not suffer from this problem plus gives you a lot of other cool benefits. One of the benefits is that the window resizes automatically for you based on the units you use in your application. Want to draw a picture at the atomic level of detail? No problem, want to draw planets circling each other? Again no problem.
Here’s a screen capture of a fractal tree created in 3-D using my new turtle.
Here’s the VPython turtle code:
if trunkLength < 5:
turnDz = random.randint(20,40)
turnDx = random.randint(20,40)
trunkShort = random.randint(10,20)
if trunkLength < 25:
# right trunk
# left trunk
# front trunk
# back trunk
If you want to check out the turtle module and play with it, you are welcome to do so: hg clone bitbucket.org/bnmnetp/v… Or send me mail.