欧拉的公式,弹跳球蟒蛇在表面的反射水平

时间:2015-12-01 01:23:58

标签: python matplotlib

下面的代码模拟了弹跳球的完美反映。什么会塑造90%?

for i in range (steps):
   t[i+1] = t[i] + dt
   x[i+1] = x[i] + v[i]*dt
   v[i+1] = v[i] - g*dt
   if x[i+1] < 0.0:    # if ball is below surface, reflect it
      x[i+1] = -x[i+1]
      v[i+1] = -v[i+1]

1 个答案:

答案 0 :(得分:1)

  v[i+1] = -v[i+1]

相当于

  v[i+1] *= -1

所以试试

  v[i+1] *= -0.9