Hinh sin
Program Hinh_sin;
Uses Crt, Graph; Type
Point_2D = Record
x, y : Real; End;
Const
Xmin: Real=0;
Ymin: Real=0;
Xmax: Real=639;
Ymax: Real=479;
MaxX: Integer=600;
MaxY: Integer=440;
Var
m,n : Integer;
ch: char;
CGx,CGy,x,b,Xgoc,Ygoc : Real;
p1,p2 : Point_2D;
(*********************)
Procedure WTV(p : Point_2D; Var q : Point_2D);
Begin
q.x:=p.x*CGx;
q.y:=p.y*CGy;
End;
(*********************)
Procedure VTS(p : Point_2D; Var q : Point_2D);
Begin
q.x:=Xgoc+p.x;
q.y:=Ygoc-p.y;
End;
(********************)
Procedure He_Truc;
Begin
Line(Round(Xgoc),0,Round(Xgoc),GetMaxY);
Line(0,Round(Ygoc),GetMaxX,Round(Ygoc));
End;
(*********************)
Function bp(x: Real) : Real;
Begin
bp:=Sin(x);
{ bp:=Cos(x);
bp:=Sqr(x); }
end;
(*********************)
Begin
clrscr;
m:=0;
InitGraph(m,n,'');
DirectVideo:=False;
MaxX:=GetMaxX;
MaxY:=GetMaxY;
b:=2*pi/360;
Xmin:=0;
Xmax:=2*pi;
Ymin:=-1;
Ymax:=1;
{
Xmin:=-PI+b;
Xmax:=pi-b;
Ymin:=-1;
Ymax:=1;
Xmin:=-50;
Xmax:=50;
Ymin:=0;
Ymax:=2500;
}
If Xmin>0 Then Xmin:=0;
If Ymin>0 Then Ymin:=0;
If Xmax<0 Then Xmax:=0;
If Ymax<0 Then Ymax:=0;
CGx:=MaxX/(Xmax-Xmin);
CGy:=MaxY/(Ymax-Ymin);
Xmin:=CGx*Xmin;
Xmax:=CGx*Xmax;
Ymin:=CGy*Ymin;
Ymax:=CGy*Ymax;
Xgoc:=0;
If Xgoc>Xmin Then Xgoc:=Round(ABS(Xmin)); Ygoc:=0;
If Ygoc<Ymax Then Ygoc:=Round(ABS(Ymax)); He_Truc;
x:=Xmin;
p1.x:=x; p1.y:=bp(x); WTV(p1, p2);
p1:=p2; VTS(p2, p2);
MoveTo(Round(p2.x),Round(p2.y)); Repeat
p1.x:=x; p1.y:=bp(x);
WTV(p1, p2);
p1:=p2; VTS(p2, p2);
LineTo(Round(p2.x),Round(p2.y));
x:=x+b;
Until x>2*pi-Xmin+b; Readln;
CloseGraph;
End.
Bạn đang đọc truyện trên: Truyen247.Pro