VPython-Python module for 3 Dimensional scientific programming

18 Jan 2008

Battle with VPython was pretty good. In my opinion VPython is a very powerful one. VPython is very interesting to make small applications. First of all we have to install VPython which is quite easy. Also we can mix music & such multimedia along with our applications, for that we just need to install python-gamepy package. Its not only for playing music but also we can add up many more things.

apt-get install python-visual

It will be very useful for implementing physics applications, students can visualize their experiments and study easily with the help of VPython. They can easily write a small code set of their experiment with the formulas.. Coding in python won't be a big problem even for a newbie :). VPython documentation is very simple with proper examples which will make our task much more easy & interesting.

hello

"HELLO" as 3D

VPython will help us to plot graphs of the equations and which can sense the mouse click, key board interactions etc. So that we can easily implement anything as we wish.For all these things we have plenty of functions in the VPython library.

Mouse clicks

We studied a lot of stuffs with sine and cosine functions , VPython made the plotting of such functions very easier.Just try the following for getting a cosine curve

from visual import * # just to import your visual python scene.title = "Cosine Curve" scene.center = vector(0,0,0) xaxis = box(length= 20, height=0.2, width= 0.5, color=color.orange) cosinecurve = curve( color = color.blue, radius=0.2) dt = 0.2 for t in arange(0,10,dt): dydt = vector( t,cos(t), 0 ); cosinecurve.append( pos=dydt, color=(1,0,0) ) rate( 500 )

Just run your .py program to get a cosine wave in ur window .

Cosine Wave

While our code is running, VPython runs another program (“parallel thread”) which periodically gets information about the attributes of our code segment. For example for finding out the position of a object, need to specify velocity of the ball ,then take a small interval of time dt , we knows velocity=displacement/time ,so we have current position , so adding current position with the product of velocity and time gap will give you the periodic updates of the position of that object using a parallel thread. So which making our task simple :)

so its worth trying on VPython :)Links to get the materials on VPython