Glider Distance Procedure

The following is maple code for the distance a glider will travel when released at a height h0 with angle theta0 and velocity v0. You might have to change the names td,vd,xd,hd of the differential equations to be consistent with your maple worksheets.

cross := (x0,y0,x1,y1) ->; x0-((x1-x0)/(y1-y0))*y0;
dist3 := proc (theta0, v0, h0)
init1:=[0,theta0,v0,0,h0];
while ( true ) do
Sol := rungekuttahf([td,vd,xd,hd] , init1, 0.1, 50):
i := 0;
while ( (i<50) and (Sol[i][5] > 0) ) do
i := i+1;
od;
if (i < 50) then
x:=cross(Sol[i-1][4],Sol[i-1][5],Sol[i][4],Sol[i][5]);
RETURN(x);
fi;
init1:=Sol[i-1]:
od;
end: