astronomia con pascal

esci turboastro.htm

configurazioni planetarie

program pianeta2;
(* spostamento pianeta e sua proiezione rispetto a stelle fisse*)

uses crt,graph;
type vet=array[1..800] of byte;
var pia1:vet;
c, anni:integer;

procedure simula;
begin
writeln('simulazione rivoluzione planetaria');
writeln('posizione pianeta interno rispetto a sole e terra ');
writeln('rivoluzione e visione prospettica del moto planetario');
writeln('rispetto alle stelle fisse:ipotesi di terra e sole fermi');
writeln;
writeln('indica numero rivoluzioni pianeta interno :1..2..3....');
readln(anni);
writeln('premi return,prego');
readln;
clrscr;
end;

procedure grafica(f:integer); (* attiva pagina grafica*)
(* coordinate finestra,colore sfondo e disegno *)
var sc,tp:integer;
stringa:string;

begin
sc:=0; (* valore risoluzione 0,1,2,3,4,5,8,9 *)
tp:=0; (* valore valido 1 - 0 palette *)
stringa:='c\scheda'; (* indica ove cercare GRAPH *)
initgraph(sc,tp,stringa); (* attiva scheda grafica *)
setbkcolor(f); (* colore sfondo *)
end;

procedure testo(x,y:integer;nome:string); (* stampa legenda testo *)
begin
outtextxy(x,y,nome);
end;

procedure pausa; (* premere return per proseguire *)
var ch:char;
begin
testo(10,400,'premi return,prego');
ch:=readkey;
end;

procedure disco; (* disegna dischi pianeti *)
begin
setfillstyle(1,2);
fillellipse(20,20,10,10);
getimage(8,8,34,34,pia1);
testo(10,60,'pianeti');
testo(290,170,'sole');
line(300,50,300,400);
setfillstyle(2,4);
fillellipse(300,400,15,15); (* terra *)
testo(320,430,'terra');
testo(10,200,'EST');
testo(500,200,'OVEST');
testo(10,420,'moto diretto :da OVEST verso EST ');
testo(10,430,'moto retrogrado:da EST verso OVEST ');
testo(150,30,'* * * * * * stelle fisse * * * * * * *');
end;

procedure moto;
var h,x,y,r1,r2,s1,c1,s2,c2,a,b,d:integer;
rad1:real;
stringa:string;

begin
x:=300;
y:=200;
r1:=100;
r2:=135;
setfillstyle(1,14);
fillellipse(300,200,20,20);
for h:=1 to anni do
begin
for c:=0 to 360 do
begin
str(c,stringa);
testo(10,250,stringa);
rad1:=c*3.14/180;
s1:=trunc(r1*sin(rad1));
c1:=trunc(r1*cos(rad1));
s2:=trunc(r2*sin(rad1));
c2:=trunc(r2*cos(rad1));
putpixel(x+s1,y+c1,2);
putpixel(x+s2,y-100,2);
putimage(x+s1-10,y+c1,pia1,1);
putimage(x+s2-10,y-120,pia1,1);
line(x,y+200,x+s1,y+c1); (* terra pianeta*)
line(x,y,x+s1,y+c1); (* sole pianeta *)
if (c=70) then testo(350,300,'elongazione ovest:visibile al mattino');
if (c=290) then testo(10,300,'elongazione est:visibile alla sera');
if (c=0) then testo(200,300,'congiunzione inferiore:invisibile');
if (c=180) then testo(200,50,'congiunzione superiore:invisibile');
if (c>290) and (c<=360) then testo(50,10,'moto retrogrado');
if (c>=0) and (c<70) then testo(50,10,'moto retrogrado');
if (c>=70) and (c<=290) then testo(50,20,'moto diretto');
if (c=70) or (c=290) or (c=180) then delay(3000);
if (c/360=int(c/360)) then delay(3000);
putimage(x+s1-10,y+c1,pia1,1);
putimage(x+s2-10,y-120,pia1,1);
setcolor(1);
line(x,y+200,x+s1,y+c1);
line(x,y,x+s1,y+c1);
testo(350,300,'elongazione ovest:visibile al mattino');
testo(10,300,'elongazione est:visibile alla sera');
testo(200,300,'congiunzione inferiore:invisibile');
testo(200,50,'congiunzione superiore:invisibile');
testo(50,10,'moto retrogrado');
testo(50,10,'moto retrogrado');
testo(50,20,'moto diretto');
testo(10,250,stringa);
setcolor(14);
fillellipse(300,200,20,20);
line(300,50,300,430);
putpixel(x+s1,y+c1,2);
end;
end;
end;

begin (* programma principale *)
clrscr;
simula;
grafica(1); (* attiva pagina grafica *)
disco;
c:=0;
moto;
pausa;
closegraph;
end.