下面的代码模拟了弹跳球的完美反映。什么会塑造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]
答案 0 :(得分:1)
此
v[i+1] = -v[i+1]
相当于
v[i+1] *= -1
所以试试
v[i+1] *= -0.9