File Exchange

## Bouncing Ball Physics

version 1.1.0.0 (2.83 KB) by
Fun Graphical User Interface that simulates the simplified physics of a ball bouncing off the ground

Updated 11 Feb 2009

The parameters are:

Colour
Gravity
Initial Y Velocity
Initial X Velocity
Vertical Speed Conservation (after hitting the ground)
Horizontal Speed Conservation (after hitting the ground)

By using different values for each parameter, the ball's motion changes each time.

### Cite As

Husam Aldahiyat (2021). Bouncing Ball Physics (https://www.mathworks.com/matlabcentral/fileexchange/22913-bouncing-ball-physics), MATLAB Central File Exchange. Retrieved .

Nanru Dai

Lupu Sabina

Do you have the differential equation for this model?

zcw1989

nice work

Disha B

Awsome. but i was wondering if it could be done in graph using pause and stop command

Peter Bone

Would be better if it included ball spin with friction - alternating directions.

some

great discussion

David

Very well done.

Luigi Giaccari

Now is clearer!! what a long discussion did it cause!!!!!

I give this 4 star, one is missing beacuse I thing is a little to simple model. But overall it is nice submission like so many comments testify.

In the end I thing this is the MEX purpose, to create discussion and improve each other.

Thanks to the Author and all commenters !!

Kenneth Eaton

Marco, I'll repeat what Husam told you, because I just tried the code myself. The default values (gravity set to 9.81, the initial vertical velocity set to 0, and the initial horizontal velocity set to 500) cause the ball to fall downward and rightward, bouncing a few times before coming to rest on the ground. If you don't get this result, check your version of MATLAB. I'm running 7.1 and didn't see any animation problems.

Husam Aldahiyat

The program didn't specify which Universe its physics laws adhered to.

Husam Aldahiyat

Maybe you have an old version of MATLAB or something, because a ball with initial Y velocity of 0 and gravity of 9.8 will go down.

This is the last time I'm reposting this ;)

John D'Errico

Luigi is correct to some extent, that rolling friction does not slow down the ball. Air resistance may be a larger factor, depending upon the velocity.

However, the point I was trying to make that a spinning ball will behave differently when it hits the ground than a ball that is not spinning, and that some of the energy of the ball can be converted from one form to another by its interactions with the ground. Also, friction with the ground is very much a factor in those interactions. A rapidly spinning ball with a high amount of rolling resistance will have a very interesting behavior.

I'll look forward to seeing a spinning, smiley, bouncy, deformable face.

Husam Aldahiyat

Marco:
ed2=100 & ed3=0 --> the ball go down and go up over the start horizontal reference .
This doesn't happen. The ball goes down and bounces for a while before settling, as what should happen. Are you sure you've tested this right?

ed2=0 & ed3=100 --> the ball go down and go up over the start horizontal reference
If there's no gravity, then mass has no meaning. The ball just floats around. Of course there can't be a "ground" and zero gravity together which is why you might think the ball motion is strange.

ed2=100 ed3=100 --> the ball go down and go up over the start horizontal reference
That's not what happens. The ball bounces and settles. Setting Yv initial to 2000 makes the ball hit the ground and then rise above the start line, which is what should happen.

Start condition: ed2=0 & ed3=1 --> the ball stay up
The ball of this program is an immaginary ball, a ball without weight.
There's no gravity, so where should the ball go?

Anyway, I thought the whole point of this program was to show off a short code that produces a fun animation of some bouncing around. With that in mind, I'm adding some new features; smiley face colour, simple deformation, and spinning.

Luigi Giaccari

Yes

Horizontal and Vertical Speed Conservation are the correct terms for what this GUI does.

Well I don't want to be annoying but I have readen something wrong in previsious comments. Friction of the ground doesn't slow down balls. Friction makes them pivot.
Without friction the ball just slips. It may stops cubes but not balls.

What really stops in real life the ball after a while it pivots it is not the ground friction, it is the ball deformability.
When it touches the ground, due the weight pressure it becomes no more a ball. The pressure distribution has resultant torque opposed to ball motion. This is called rolling resistance and it is about 1/100 1/1000 the ground friction.
This is the reason balls runs faster than cubes.

John D'Errico

Luigi is correct here. There is a problem in the model, but a minor one I think.

Friction should be a retarding force, and as friction increases, the ball should slow down. So for friction above 1, the ball could not speed up. "Elasticity" in the model is used as a coefficient of restitution. This is essentially the fraction of the kinetic energy that is conserved in a bounce. So for elasticity greater than 1, we expect the ball to bounce higher each time. This is acceptable in the vertical direction, if you wish to model an uber-rubber ball. I might also be tempted to rename "elasticity" to "restitution", which is arguably a more accurately descriptive name here.

If you want to model the horizontal physics in this way, "friction" should slow down the ball at each bounce, for any positive value of friction, and high friction should slow it faster. Were you to allow a negative frictional value, it could then arguably speed up after a bounce.

If you make some changes, here are a few other neat ideas. Make the ball squishable, so that when it does bounce, it deforms. The "elasticity" parameter would naturally inversely govern the extent of the deformation. One might also allow the ground to deform too, absorbing some of the energy of the ball at each bounce. Again, a negative term here might increase the energy after a bounce.

Introduce a secondary frictional retarding force, perhaps proportional to the square of the velocity in the air.

Allow the ball to start out spinning, with some rotational velocity, in either direction. Thus, when the ball hits the ground, the angular momentum in the spinning ball can be transformed into a horizontal component of momentum. The friction with the ground would govern the amount of momentum transferred. This would work in the opposite direction too. If the ball is not spinning to start with, when it hits the ground, that can start it to spin.

Add a smiley face to the ball. After a the first bounce, make it look surprised. If the ball is spinning, the smiley face could rotate too, which would be a good way to show the spin rate.

A really complete model might even include fluid effects due to the spin. Thus a high rate of spin would help the ball to fly a bit further, or slow it down, depending on the direction of spin. Think of a golf or tennis ball, and how it behaves. One might modulate this with a surface texture parameter, shown as a rough or smooth ball. The viscosity of the medium would then be factor. (Don't you love it when someone comes up with this many features to add to your code? Hey, I'm not the one who would do the work.)

Regardless, I do like the help. It seems rare to find help in a gui tool, and even more rare that the help is good and well written, so I was very pleasantly surprised here.

I'd rate this as less than 5 only because the friction is clearly incorrect physical behavior. But I'd change my rating to a 5 as soon as that is repaired. And, I'm not willing to decrease my rating below 4.50000001 anyway, so I'll just round it up to a 5. I'll still root for some of those other terms I've described to be added to the model though.

Husam Aldahiyat

I've sent an update which changes the titles of the edit boxes.

Friction -> Horizontal Speed Conservation
Elasticity -> Vertical Speed Conservation

I believe this was the problem since in reality increasing friction would make the ball travel a shorter distance while in the GUI it was the opposite case. It was made this way deliberately but the choice of wording was inappropiate. Please check the updated version to see if your questions were met.

Luigi Giaccari

Nice GUI but there is something wrong in the mathematical model.

This not a bouncing ball, in the simplest model, the friction value, I think you mean the friction with the ground, should affect the way ball pivots not length after that the ball stops.

For zero friction the ball just stops why?
-It should instead bouncing without pivoting.

-With intermediate values should slides and pivots dependending on materials data.

-With high friction should pivots without sliding.

If you try to insert a friction value >1 the ball accelerates, and this isn't phisical.

I saw you study mecatronics, you can realize that with Working Model software, or simpler throwing a ball.

I thing it need to be fixed

##### MATLAB Release Compatibility
Created with R2007a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux