Bouncing Ball Animation – Using Events with ODE
Jiro's pick this week is "Bouncing Ball: Tutorial for ode45 events" by Matthew Kelly.
Using animation is a great way to convey information. By animating something physical, it has an added effect of tying concepts with experience or intuition. This tutorial by Matthew is about using events with ordinary differential equation solver ode45, or any other ODE solver for that matter. He uses a bouncing ball example to show the effect of events, represented as the act of the ball coming into contact with the ground. Since a ball typically bounces over and over again, he repeatedly calls ode45 with each calculation separated by an event (contact). The simulation takes into account the energy loss when the ball bounces, defined by the coefficient of restitution. Add to that a nice terrain defined by a few sinusoids, then you get a nice animation of the ball bouncing all over the place.
Matthew has documented the code very well, so it's easy to pick up and understand. He's modularized the code so that you can customize it to your needs. For example, he has a single function Set_Parameters that, well... sets your parameters. The function groundHeight defines the terrain, and the function Animate creates the animation.
I added a bit of interactivity to the terrain creation, and here are some interesting terrains I tested.
If you found this entry interesting, Matthew has contributed quite a bit to the File Exchange. Be sure to check it out.
Comments
Let us know what you think here or leave a comment for Matthew.
- 범주:
- Picks
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.