Draw sin, cos, tangent and cotangent with axis

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: KMP (Club of young programmers)
sin-cos.pngAuthor: Ján Benkovič
web: www.tbteacher.host.sk

Program: Sin-cos.pas
File exe: Sin-cos.exe

Draw sin, cos, tangent and cotangent with axis.
{ SIN-COS.PAS                            Copyright (c) Jan Benkovic }
{ Vykresli sin, cos, tangens a kotangens na suradnicovu os.         }
{                                                                   }
{ Datum:11.05.2000                             http://www.trsek.com }
 
uses graph,crt;
var
 a,gd,gm : integer;
 c:char;
 
procedure vycisti;
 begin
  cleardevice;
  setcolor(white);
  line(150,1,150,480);
  line(0,240,640,240);
  outtextxy(140,245,'0');
  outtextxy(630,245,'X');
  outtextxy(138,1,'Y');
  line(228 ,240, 228,235);
  outtextxy(218,250,'2/PI');
  line(307 ,240, 307,235);
  outtextxy(302,250,'PI');
  line(385 ,240, 385,235);
  outtextxy(365,250,'2*PI/3');
  line(465 ,240, 465,235);
  outtextxy(452,250,'2*PI');
  setcolor(red);
  outtextxy(1,1,'Sinus');
  setcolor(blue);
  outtextxy(1,11,'Cosinus');
  setcolor(green);
  outtextxy(1,21,'Sinus+Cosinus');
  setcolor(3);
  outtextxy(1,31,'Tangens');
  setcolor(5);
  outtextxy(1,41,'CoTangens');
 end;
 
begin
 detectgraph(gd,gm);
 initgraph(gd,gm,'');
 vycisti;
 moveto(150,240);
 for a:= 1 to 360 do
  begin
   delay(2);
   setcolor(red);
   lineto(a+150,-round(sin(0.02*a)*90)+240);
  end;
 c:=readkey;
 vycisti;
 moveto(150,150);
 for a:= 1 to 360 do
  begin
   delay(2);
   setcolor(blue);
   lineto(a+149,-round(cos(0.02*a)*90)+240);
  end;
 c:=readkey;
 vycisti;
 moveto(150,150);
 for a:= 1 to 360 do
  begin
   setcolor(green);
   delay(2);
   lineto(a+149,-round((cos(0.02*a)*90)+(sin(0.02*a)*90))+240);
  end;
 c:=readkey;
 vycisti;
 moveto(150,240);
 for a:= 1 to 360 do
  begin
   setcolor(3);
   delay(2);
   lineto(a+150,-round((sin(0.02*a)*90)/(cos(0.02*a)))+240);
  end;
 c:=readkey;
 vycisti;
 moveto(150,0);
 for a:= 1 to 360 do
  begin
   setcolor(5);
   delay(2);
   lineto(a+150,-round((cos(0.02*a)*90/(sin(0.02*a))))+240);
  end;
 c:=readkey;
end.