3. Берілген полярлық координаталарында функцияның графигін салу. Гүл салу. USES CRT,GRAPH;
CONST
N=1000;A=0;B=24*PI;R=5;MX=1;MY=1;R1=60;
VAR
DD,RR:INTEGER;
X0,Y0,X1,Y1:INTEGER;
X,Y,DX:REAL;
FUNCTION F(T:REAL):REAL;
BEGIN
F:=(R1+R)*SIN(R*T/R1)-(R1+R)*SIN(T+R*T/R1)
END;
FUNCTION W(T:REAL):REAL;
BEGIN
W:=(R1+R)*COS(R*T/R1)-(R1+R)*COS(T+R*T/R1)
END;
BEGIN
DD:=DETECT;
INITGRAPH(DD,RR,'C:\BP\DOC\BGI');
X0:=GETMAXX DIV 2;
Y0:=GETMAXY DIV 2;
DX:=B/N;
X:=A;
X1:=ROUND(W(X)*MX+X0);
Y1:=ROUND(Y0-F(X)*MY);
MOVETO(X1,Y1);
WHILE X<=B DO
BEGIN
X:=X+DX;
X1:=ROUND(W(X)*MX+X0);
Y1:=ROUND(Y0-F(X)*MY);
LINETO(X1,Y1)
END;
REPEAT UNTIL KEYPRESSED;
CLOSEGRAPH
END.
program GrFunPol;
uses crt;
const
n=1000; a=0; b=24*pi; r=5; mx=1; my=1; R1=60;
var
dd,rr:integer;
x0,y0,x1,y1:integer;
x,y,dx:real;
function F(t:real):real;
begin
F:=(R1+r)*sin(r*t/R1)-(R1+r)*sin(t+r*t/R1)
end;
function W(t:real):real;
begin
W:=(R1+r)*cos(r*t/R1)-(R1+r)*cos(t+r*t/R1)
end;
begin
dd:=detect;
initgraph(dd,rr,'c:\bp\doc\bgi');
x0:=getmaxx div 2; y0:=getmaxy div 2; dx:=b/N;
x:=a; x1:=round(W(x)*mx+X0) ; y1 :=round(Y0-F(x)*my) ;
moveto (x1,y1) ;
while x<=b do
begin
x:=x+dx; x1:=round(W(x)*mx+X0) ; y1:=round(Y0-F(x)*my) ;
lineto(x1,y1)
end;
repeat until keypressed;
closegraph
end.
4. Дөңгелектің спираль бойымен қозғалысы
PROGRAM SpirDohn;
USES CRT,GRAPH;
CONST N=100; R=5;MX=10; MY=10; A=0; B=8*PI;
VAR dd,rr:INTEGER;
XO,YO,X1,Y1:INTEGER;
X,Y,DX:REAL;
FUNCTION F(T:REAL):REAL;
BEGIN
F:=T*sin(T)
END;
FUNCTION W(T:REAL):REAL;
BEGIN
W:=T*COS(T)
END;
BEGIN
DD:=DETECT;
INITGRAPH(DD,RR,'C:\BP\DOC\BGI');
XO:=GETMAXX DIV 2;
YO:=GETMAXY DIV 2;
DX:=(B-A)/N;
X:=A;
X1:=ROUND(X*MX+XO);
Y1:=ROUND(YO-F(X)*MY);
CIRCLE(X1,Y1,R);
WHILE X<=B DO
BEGIN
SETCOLOR(0);
CIRCLE(X1,Y1,R);
X:=X+DX;
X1:=ROUND(X*MX+XO); Y1:=ROUND(YO-F(X)*MY);
SETCOLOR(15);
CIRCLE(X1,Y1,R);
DELAY(2000)
END;
REPEAT UNTIL KEYPRESSED;
CLOSEGRAPH
END.