{************************************************************************** * THE BOUNCING BALL * * ----------------------------------------------------------------------- * * Explanations: * * * * Let us consider an elastic ball dropped with a horizontal speed Vx from * * a height H. Here are the main equations to calculate the successive * * rebounds on the ground: * * * * Initializing: * * The first part of the trajectory is a parabolic section, upwards orien- * * ted. From the physical laws for a falling body, we know that: * * Vy = sqrt(2GH) and V0 = sqrt(Vx² + Vy²) with theta=arctan(Vx/Vy), * * where V0 is the speed at ground level and theta = pi - angle of V0 with * * the Ox axis. * * The ball moves with the horizontal speed Vx and the vertical speed -Vy * * during time t=Vy/G until it reaches the ground (G=gravity acceleration).* * Hence the horizontal distance run is x2=Vx*t=Vx*Vy/G. * * The equation of the parabolic section is: y = -(H/x2²)*x + H from x=0 * * to x=x2. * * * * Rebounds: * * For each rebound, the initial speed V0 is multiplied by a damping * * coefficient, called amort (<1), but the theta initial angle is kept the * * same. The previous x2 value becomes the next x1 value. The parabolic * * equation of the next trajectory section has the complete form: * * y = a*x² + b*x + c (1) * * P=2*Vx*Vy/G is the correct length for all the rebounds. Hence the next * * x2 = x1 + P. The parabola summit coordinates are the following: * * xs = (x1+x2)/2 and ys = (V0²*sin²(theta))/(2G) * * So to draw the trajectory section of a rebound, we have to know the * * equation of a parabola passing through the 3 points: (x1,0), (x2,0) and * * (xs,ys). This leads to the following linear system to solve of order 3: * * a*x1² + b*x1 + c = 0 * * a*xs² + b*xs + c = 0 * * a*x2² + b*x2 + c = 0 * * where the unknowns are a, b, c, the coefficients of the parabola (1). * * Using the Cramer's method, we calculate the main determinant Dp and the * * three sub-determinants, Da, Db, Dc. We find: * * Dp = x1²*(xs-x2) + x2²*(x1-xs) + xs²*(x2-x1) * * Da = ys*(x2-x1) Db = ys*(x1²-x2²) Dc = ys*x1*x2*(x2-x1) * * Hence: a = Da/Dp b = Db/Dp c = Dc/Dp * * Now we can draw the parabolic section of the next rebound in [x1,x2]. * * We continue the same process until the required number of rebounds is * * reached. * * ----------------------------------------------------------------------- * * Reference: * * From "Graphisme dans le plan et dans l'espace avec Turbo Pascal 4.0 de * * R. Dony - MASSON 1990 page 113" [BIBLI 12]. * * * * TPW Release By J-P Moreau, Paris. * * (www.jpmoreau.fr) * **************************************************************************} Program Rebounds; Uses WinCrtMy, WinProcs, Strings, Type_def, CrtGr2D; Const Height = 12; G = 9.81; step = 0.005; Var amort,vx,vy,v0,a,b,c: real; x1,x2,xs,ys,angle,Length: real; bounds,nrebounds: byte; Procedure Data; begin clrscr; writeln; writeln(' The bouncing ball'); writeln(' -----------------'); writeln; write(' Initial horizontal speed: '); readln(vx); writeln; write(' Damping coefficient.....: '); readln(amort); writeln; write(' Number of rebounds......: '); readln(nrebounds) end; Procedure Init; begin bounds:=0; x1:=0.0; vy:=sqrt(2*G*Height); angle:=ArcTan(vy/vx); v0:=sqrt(sqr(vx)+sqr(vy)); x2:=vx*vy/G; a:=-Height/sqr(x2); b:=0.0; c:=Height end; Procedure DrawParabol(pt1,pt2:real); var x,y: real; begin x:=pt1; MoveXY(CrtDc,x,0.0); while x