【发布时间】:2018-03-28 20:58:32
【问题描述】:
我必须创建一个地球围绕太阳旋转的简单模拟。我不能使用球坐标,我必须使用引力能量和速度方程到目前为止我有这个:
earth = sphere (color = color.green, radius = 10**6)
sun = sphere (color = color.yellow, radius = 10**7)
earth.mass = 5.972*10**24
sun.mass=1.989*10**30
d=1.496*10**8
v=(2*math.pi*d)/(3.154*10**7)
earth.velocity = vector(0.0, 0.0, -1*v)
earth.pos = vector(d, 0, 0)
sun.pos = vector(0,0,0)
dt = 50000
t = 0.0
P=0
while True:
rate(400)
f=(6.667*10**.11)*((earth.mass*sun.mass)/d**2)
P = P + f*dt
earth.velocity = P/earth.mass
earth.pos = earth.pos + earth.velocity*dt
t=t+dt
我不知道我是否在物理方面或编码方面遗漏了一些东西,但是当我运行它时,什么也没有出现。提前致谢!
【问题讨论】: