Model/formula for bouncing ball I'm programming an animation of a bouncing ball, and I want it to be as realistic as possible.
I fully understand the physics while the ball is rising and falling: It accelerates downward at 9.8 meters/second/second.
But once it hits the ground, I'm lost. I know that it experiences some compression which translates it's velocity upward again, at which point gravity is again the only force acting on it. But I don't know how to model the compression and deflection of the ball hitting the ground.
(Also, I'm only dealing with strictly vertical linear velocity and acceleration. The ball isn't traveling horizontally or rotating at all. And I'm assuming negligible loss to air resistance.)
I know there are constants to deal with: how much the ball resists compression and how much energy is lost during the bounce, but I don't know how they are related.
Can anybody give me a one- or two-paragraph explanation and/or (a) formula(e) and/or point me to a resource where I can read more? (yes, I've already spent an hour or so googling it)
I'm happy to continue reading about it until I understand, I just don't know where to turn at this point.
Thanks in advance!
 A: You say you are ignoring friction of the air, but assume a partially inelastic collision. That means we can break the problem into two parts:


*

*While the ball is not in contact with the ground, the height at time $t$ after the last bounce at $t_0$ is given by $$h(t+t_0) = v_0 t - \frac12 g t^2$$ where $v_0$ is the velocity just after the bounce. This velocity will change from one bounce to the next.

*During the impact, the ball will deform and there will be friction. The exact shape of the ball during the impact is hard to capture in a simple equation because it depends on the composition of the ball and the floor. As a simplifying assumption, consider the ball to be a "mass on a slightly lossy spring with a spring constant $k$"; then the ball will exhibit (approximately) damped simple harmonic motion during the impact: this means that the impact time will be independent of the impact velocity(!)


The coefficient of restitution is a parameter of a ball/surface, and reflects the fraction of velocity just after the bounce divided by the velocity just before. For a golf ball, this can be as high as 0.8; for a tennis ball it is around 0.75.
Using $\rho=0.75$, if you drop a ball from a height of 5 m (and putting $g=10~m/s^2$ for convenience) it would land after 1 second with a velocity of 10 m/s, and after the bounce (some short time $\Delta t$) it would come up again with a lower velocity $v_1 = 7.5 m/s$. The time spent in the air until the next bounce is given by $$t_1 = 2\frac{v_1}{g} = 2\rho \frac{v_0}{g}$$ 
While the ball is in contact with the ground, we can consider its center to move in an approximately sinusoidal fashion - as I said, the important thing is that the contact time is independent of the drop height (on the assumption of linear spring constant). In reality, as the ball deforms more, the spring constant will increase - which will actually make the contact time shorter as the impact velocity is higher. But for your simulation that is unlikely to matter.
To get from the above to a "mathematical model" you might want to modify this python code to your needs:
from math import sqrt
import matplotlib.pyplot as plt

h0 = 5         # m/s
v = 0          # m/s, current velocity
g = 10         # m/s/s
t = 0          # starting time
dt = 0.001     # time step
rho = 0.75     # coefficient of restitution
tau = 0.10     # contact time for bounce
hmax = h0      # keep track of the maximum height
h = h0
hstop = 0.01   # stop when bounce is less than 1 cm
freefall = True # state: freefall or in contact
t_last = -sqrt(2*h0/g) # time we would have launched to get to h0 at t=0
vmax = sqrt(2 * hmax * g)
H = []
T = []
while(hmax > hstop):
  if(freefall):
    hnew = h + v*dt - 0.5*g*dt*dt
    if(hnew<0):
      t = t_last + 2*sqrt(2*hmax/g)
      freefall = False
      t_last = t + tau
      h = 0
    else:
      t = t + dt
      v = v - g*dt
      h = hnew
  else:
    t = t + tau
    vmax = vmax * rho
    v = vmax
    freefall = True
    h = 0
  hmax = 0.5*vmax*vmax/g
  H.append(h)
  T.append(t)

print("stopped bouncing at t=%.3f\n"%(t))

plt.figure()
plt.plot(T, H)
plt.xlabel('time')
plt.ylabel('height')
plt.title('bouncing ball')

This code produces the following plot:

A: Visual Solutions (Now Altair) makes VisSim Software. Here is a demo block diagram that they have used to simulate a bouncing ball:
The $1/s$ blocks are integrator blocks from the VisSim library.
The plot of the bouncing ball with these parameters is shown below.

If you are interested in running this, the demo comes with the install and you can download a free 60 day trial here 
A: Well the difficulty is when the ball in contact with wall. Few things you can consider. 


*

*elastic impact. In this case, you can treat the ball as an elastic spring. When it impacts the wall with a speed, the kinetic energy will be converted to the spring's potential energy. And then, after it reaches the maximum deformation, the ball will spring back into space. The deformation direction is normal to the wall.

*inelastic impact. This is similar to the above except the ball recovers only a fractional of kinetic energy. This is closer to reality. The loss is usually described using coefficient of restitution. 

*inelastic impact with friction. When the ball hits a wall with an angle, the ball can slide on the surface. This becomes more close to reality. 

*air drag. When the ball is moving is space, there is air drag force to slow it down. 

