经典物理情景
当一个小物体被抛出去之后,其轨迹会形成特殊的形状。抛体运动分为:平抛运动、斜抛运动、竖直抛体运动。平抛和斜抛运动的轨迹会形成包络线和包络面。
程序演示
动图演示
斜抛包络线
斜上抛包络面
平抛包络面
斜下抛包络面
程序源码
g = 9.8; size =0.3; height = 0; m = 1; theta= 3*pi/180; v0=10
scene = canvas(width=300, height=300,x=0, y=0, center = vector(0,0,0),
background=vector(0.5,0.6,0.5),range=12)
floor = box(pos=vector(0,size,0),length=24, height=0.07,
width=3, color=color.cyan)
ball = sphere(pos=vector(0,size,0),radius = size, color=color.yellow,
make_trail= True,trail_type="points", interval=10)
Fg = vector(0, -m*g, 0)
ball.a=Fg/m
ball.v = vector(v0*cos(theta), v0*sin(theta), 0)
gd1 = graph(title = "R-theta", width=300, height=300, xtitle="theta", ytitle="R")
f1 = gcurve(color=color.red)
gd2 = graph(title = "T-theta", width=300, height=300, xtitle="theta", ytitle="T")
f2 = gcurve(color=color.blue)
t=0.0; dt=0.0001
while True:
rate(100000)
t += dt
ball.v += ball.a*dt
ball.pos += ball.v*dt
if ball.pos.y <= size:
f1.plot(pos=(theta*180/pi,ball.pos.x))
f2.plot(pos=(theta*180/pi,t))
t=0
theta += 3 * pi/180
if theta>pi:
break
ball.pos = vector(0, size, 0)
ball.v = vector(v0*cos(theta), v0*sin(theta), 0)
评论 (0)