from visual import * scene.background=(1,1,1) scene.autoscale=1 scene.background=(1,1,1) drop_height = 8.0 mass = 0.500 unstr_length = 2.0 k_elastic = 3.0 floor = box(length=1.0, height=0.5, width=1.0, color=color.blue) rad = 0.2 ball = sphere(pos=(0,drop_height,0), radius=rad, color=color.red) ball.velocity = vector(0,0,0) scene.autoscale=0 dt = 0.005 while 1: rate(100) ball.pos = ball.pos + ball.velocity*dt if ball.pos.y < (drop_height-unstr_length): stretch = drop_height - unstr_length - ball.pos.y v1 = ball.velocity.y ball.velocity.y = ball.velocity.y +(-9.8 + (k_elastic/mass)*stretch)*dt v2 = ball.velocity.y if (v1<0) and (v2>=0): print "Ground Clearance: ", ball.pos.y," meters" else: ball.velocity.y = ball.velocity.y - 9.8*dt