您的位置:首页 > 其它

没事情可以这样找电影看

2011-05-17 17:40 507 查看
本作品采用知识共享署名-非商业性使用-相同方式共享 3.0 Unported许可协议进行许可。允许非商业转载,但应注明作者及出处。

作者:liuyuan_jq
2011-04-10

Fromhttp://wiki.showmedo.com/index.php/PythonThompsonVPythonSeries

from visual import *
scene.width = 400
scene.height = 300
scene.autoscale = 0
scene.range = (100,100,100)
scene.center = (0,40,0)
ball = sphere(pos=(0,100,0),radius=2)
ground = box(pos=(0,-1,0),size=(10,2,10))
gravity = 9.8 # m/s**2
seconds = 0
dt = .01
finished = False
while not finished:
rate(100) # go thru the loop no more than 100 times/s
seconds += dt
# position equation: y(t) = y0 + v0*t + .5 * a * t**2
ballHeight = 100 - .5 * gravity * seconds**2
ball.pos = vector(0,ballHeight,0)
if ballHeight - 2 < 0:
finished = True
print "seconds to fall: " + str(seconds)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐