This code below models perfect reflection of a bouncing ball. What would model 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]
This
v[i+1] = -v[i+1]
is equivalent to
v[i+1] *= -1
So try
v[i+1] *= -0.9
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.