Application: Bouncing Ball - Maple Help

Ball Bouncing on Hilly Terrain

 The following application demonstrates how event modeling in the dsolve command can be used to model a ball bouncing on a hilly terrain.

 > $\mathrm{restart};\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$
 > $\mathrm{with}\left(\mathrm{plots}\right):$

Define the Surface

We define the surface, surf, in the line below.  It is possible to modify this equation to show different "terrains".

 >
 > $\mathrm{plot}\left(\mathrm{surf},x=0..10,\mathrm{scaling}=\mathrm{constrained}\right)$

Derive the Hilly Surface

The velocity vector of a ball:

 > $V≔\mathrm{Vector}\left(\left[\stackrel{\mathbf{.}}{x}\left(t\right),\stackrel{\mathbf{.}}{y}\left(t\right)\right]\right):$

The surface normal:

 >
 > $N≔\mathrm{eval}\left(N,x=x\left(t\right)\right)$
 ${N}{:=}\left[\begin{array}{c}\frac{{-}{\mathrm{cos}}{}\left({x}{}\left({t}\right)\right){+}{0.2}{}{\mathrm{sin}}{}\left({4}{}{x}{}\left({t}\right){+}{\mathrm{sin}}{}\left({4}{}{x}{}\left({t}\right)\right)\right){}\left({4}{+}{4}{}{\mathrm{cos}}{}\left({4}{}{x}{}\left({t}\right)\right)\right){+}{0.2}}{\sqrt{{1}{+}{\left({-}{\mathrm{cos}}{}\left({x}{}\left({t}\right)\right){+}{0.2}{}{\mathrm{sin}}{}\left({4}{}{x}{}\left({t}\right){+}{\mathrm{sin}}{}\left({4}{}{x}{}\left({t}\right)\right)\right){}\left({4}{+}{4}{}{\mathrm{cos}}{}\left({4}{}{x}{}\left({t}\right)\right)\right){+}{0.2}\right)}^{{2}}}}\\ \frac{{1}}{\sqrt{{1}{+}{\left({-}{\mathrm{cos}}{}\left({x}{}\left({t}\right)\right){+}{0.2}{}{\mathrm{sin}}{}\left({4}{}{x}{}\left({t}\right){+}{\mathrm{sin}}{}\left({4}{}{x}{}\left({t}\right)\right)\right){}\left({4}{+}{4}{}{\mathrm{cos}}{}\left({4}{}{x}{}\left({t}\right)\right)\right){+}{0.2}\right)}^{{2}}}}\end{array}\right]$ (2.1)

The velocity vector after reflection across the surface normal:

 >
 > $\mathrm{V_reflect}\mathit{:=}\mathrm{simplify}\left(\mathrm{V_reflect},\mathrm{symbolic}\right):$

Restitution coefficient:

 >

Using  represents an inelastic collision between the ball and the surface, whereas using  represents an elastic collision.

Differential Equations and Initial Conditions

Gravity acts in the -y direction:

 > $\mathrm{deqs}≔\stackrel{\mathbf{..}}{y}\left(t\right)=-9.81,\stackrel{\mathbf{..}}{x}\left(t\right)=0:$
 > $\mathrm{ics}≔\mathrm{D}\left(x\right)\left(0\right)=0,\mathrm{D}\left(y\right)\left(0\right)=0,x\left(0\right)=2,y\left(0\right)=4.5:$

Solve and Animate the Differential Equations

 >

Animate the Ball Bouncing on the Terrain

 > $\mathrm{xanim}≔\mathrm{subs}\left(\mathrm{sol},x\left(t\right)\right):\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{yanim}≔\mathrm{subs}\left(\mathrm{sol},y\left(t\right)\right):$
 > $\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{p2}≔\mathrm{animate}\left(\mathrm{pointplot},\left[\left[\mathrm{xanim}\left(t\right),\mathrm{yanim}\left(t\right)\right],\mathrm{symbol}=\mathrm{solidcircle},\mathrm{symbolsize}=15,\mathrm{color}=\mathrm{black}\right],t=0..10,\mathrm{frames}=150\right):$
 > $\mathrm{display}\left(\mathrm{p1},\mathrm{p2},\mathrm{view}=\left[0..10,0..5\right],\mathrm{scaling}=\mathrm{constrained}\right)$