uses math;
const
rand = 10;
maxsteps = 500;
var
WTable: array of double;
v0, a, g, h, xmax, ymax: double;
procedure berechnen;
var
d, w: double;
i: integer;
begin
w := degtorad(a);
xmax := (sqr(v0) * 2 * sin(w)) / g + h; // maximale Weite
ymax := (sqr(v0) * sqr(sin(w))) / (2 * g) + h; // maximale Höhe
i := 0;
repeat
d := tan(w) * i - (g / (2 * sqr(v0) * sqr(cos(w))) *
sqr(i)) + h;
setlength(WTable, i + 1);
WTable[i] := d;
inc(i);
until (d < 0) or (i > maxsteps);
end;
procedure anzeigen(canvas: TCanvas);
var
x, y, NullLinie, links, steps: integer;
begin
links := rand;
NullLinie := round(ymax + rand);
steps := high(WTable);
with canvas do begin
pen.color := clblack;
moveto(links, NullLinie);
lineto(links, NullLinie - round(h));
pen.color := clgray;
moveto(links, NullLinie);
lineto(links + steps, NullLinie);
pen.color := clred;
moveto(links, NullLinie - round(h));
for x := 0 to steps do begin
if x = steps then y := 0 else
y := round(WTable[x]);
lineto(x + links, NullLinie - y);
end;
end;
end;
// Beispielaufruf
procedure TForm1.Button5Click(Sender: TObject);
begin
button5.enabled := false;
g := 9.81; // Gravitation in m/s*s
h := 35; // Abwurfhöhe in m
a := 45; // Abwurfwinkel in Grad
v0 := 60; // Anfangsgeschwindigkeit in m/s
berechnen;
refresh;
anzeigen(Canvas);
WTable := nil;
button5.enabled := true;
end;