//
you're reading...
Uncategorized

3D Graphics Programming Using VPython

Download and install VPython by going to http://vpython.org/

Here is a gallery of some projects you can do using VPython

from visual import *        

scene = display(title='Bouncing ball')
ball = sphere(pos=(0,5,0), radius=1, color=color.yellow)    
floor = box(pos=(0,-5,0), length=8, height=0.2, width=4)

dt = 0.01           # time step size
v = 0.0             # initial velocity

while True:         # loop forever
    rate(400)       # limit animation rate to 400 loops/sec
    ball.pos.y = ball.pos.y + v*dt      # update y position
    if ball.pos.y > floor.y + ball.radius:  
        v = v - 9.8*dt      # above floor, update velocity
    else:                               
        v = - v             # below floor, reverse velocity

Screen Shot 2015-03-04 at 10.18.38 AM

Advertisement

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: