Dze je subor www.TrSek.com/zadania/graf.pas{ GRAF.PAS Copyright (c) TrSek alias Zdeno Sekerak }
{ }
{ Graf funkcie }
{ y:=(10/3)*(1-exp((-1*x)/3)*(cos(1/3*sqrt(0.8)*x)+(1/sqrt(0.8) }
{ *(sin((1/3)*(sqrt(0.8)*x)))))) }
{ alebo inej zapisanej do FUNKCI(x:real) }
{ Vstup : rozsah x, y zobrazenej funkcie }
{ Vystup: graf funkcie }
{ Vyzaduje subor EGAVGA.BGI, GRAPH.TPU }
{ }
{ Datum:10.04.1995 http://www.trsek.com }
program graf_funkcie;
uses crt,dos,graph;
var x,y:real;
gd,gm:integer;
x1,x2:real;
krok,rozlis,grund:real;
xp,yp:integer;
function funkci(x:real):real;
var y:real;
begin
{ y:=(1-x)/(3+x);}
y:=(10/3)* (1-exp((-1*x)/3)*(cos(1/3*sqrt(0.8)*x)+(1/sqrt(0.8)*(sin((1/3)*(sqrt(0.8)*x))))));
funkci:=y;
end;
begin
x1:=-10;x2:=30;krok:=(x2-x1)/640;
rozlis:=5;
grund:=100;
write('Zadaj Xlave (-10) = ');readln(x1);
write('Zadaj Xprave (30) = ');readln(x2);
write('Zadaj rozlisenie Y (5) = ');readln(rozlis);
write('Zadaj vzdialenost Y osi od dlazky (100) = ');readln(grund);
gd := Detect;
InitGraph(gd,gm,'');
setcolor(Yellow);
setbkcolor(Blue);
x:=x1;
line(0,round(480-grund),640,round(480-grund));
line(round(abs((x1)/krok)),0,round(abs((x1)/krok)),480);
repeat
x:=x+krok;
y:=funkci(x)*rozlis;
putpixel(round(abs((x1-x)/krok)),480-round(grund+y),Yellow);
until (x>x2);
repeat until keypressed;
closegraph;
end.