# Bouncing ball simulation computer science

In my Computer science class I was given a problem where I have to simulate a bouncing ball using "real physics". I have been trying to find a equation that will simulate the height of the bounce given a gravity and an arbitrary mass. And I will need to calculate the next bounce and it's height. A lot of the equations I've found require a time. But I don't really care about a time, all I want is to get the next height after the previous bounce until it finally hits height of 0 or close to it. I haven't taken a physics class since high school( 5 years ago) and that was basic physics.

• If you aren't considering any losses during the bounce, it'll reach exactly the same height every time. Otherwise you could use conservation of energy and put in an energy loss every time it bounces. Newton's laws + conservation of energy hold the answer. – Kitchi Jun 2 '13 at 6:21
• You'll be interested in the coefficient of restitution which is a measure of of energy loss in a collision. en.wikipedia.org/wiki/Coefficient_of_restitution – Brandon Enright Jun 2 '13 at 6:37
• For reference, the computation part of the proposed problem is off-topic on Physics.SE (use SciComp.SE instead), but I read the question as being focused on the physics of bouncing and the programming project as merely the motivation. The physics is, obviously, on-topic. – dmckee Jun 2 '13 at 7:46
• Wow I didn't know there was a computer science stack exchange. There are so many. Thank you. – sydney Jun 2 '13 at 8:41
• Also I do want the height of the bounce to decrease with respect to gravity(Ignore air resistance). – sydney Jun 2 '13 at 9:02

The question title indicates a 'simulation', yet you state that you 'don't really care about time.' Your question does not need to be solved with a computer program - it's fairly straightforward to do by hand. Let $H$ be the maximum height, $m$ be the mass, $g$ be the gravitational acceleration, $9.81 \frac {m}{s^2}$, $v$ be the velocity, $C_R$ be the coefficient of restitution. $C_R$ is a ratio of the final velocity to the initial velocity, before and after the collision, so: $$C_R=\frac{v_f}{v_i}$$ $C_R$ should be found emprically. For example, a bowling ball and a basketball have different $C_R$ when dropped from the same height (the initial velocity is the same, the final velocities are different). Let $C_R=.5$ (you can change it later on).
Use energy conservation to find the velocity of the ball when it hits the ground:$$mgH=\frac{1}{2}mv^2$$ $$v=\sqrt{2gH}$$
When it rebounds, from the ground, the new velocity will be:$$v_f=v_iC_R$$
Use energy conservation again to find the new max height:$$\frac{1}{2}mv^2=mgH$$ $$H=\frac{v^2}{2g}$$
You can see that the speed of the ball coming down is exactly the same as the speed of the ball coming up (neglecting air resistance), thus we repeat the equations for $v_f$ and the max height $H$ until we're satisfied.
• @sydney There is another way to approach this problem, which doesn't require you to know ahead of time the max height or speed at impact. In fact, you can let the computer 'step through' time in little increments, and by applying the laws of motion, record the position and velocity of the ball at each point in time. However, this is geared more toward simulation and not physics. You would need to understand vectors, and also primarily use the equation: $y_f=y_i+vt-\frac{1}{2}gt^2$. – Greg Jun 2 '13 at 17:47