diffrazione

esci otticaturbo.htm

program diffra1;
(* elementi di ottica :interferenza *)
(* disco 70 dispensa 55 con turbo pascal v.5 *)

uses crt,graph;
type string50=string[50];
var
opzione,sosta:integer;

procedure presenta;
begin
settextstyle(1,0,4);
setcolor(5);
outtextxy(30,30,'elementi di ottica ');
outtextxy(30,60,'interferenza');
outtextxy(30,160,'premi return,prego');readln;
settextstyle(0,0,0);
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:='bgi'; (* 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 testo1(x,y:integer;nome:string); (* cancella legenda testo *)
begin
setcolor(1);
outtextxy(x,y,nome);
setcolor(14);
end;

procedure pausa; (* premere return per proseguire *)
var ch:char;
begin
sound(300);
testo(10,440,'premi return,prego');
ch:=readkey;
setcolor(1);
testo(10,440,'premi return,prego');
nosound;
end;

procedure pausa1; (* premere return per proseguire *)
var ch:char;
begin
sound(500);delay(1000);nosound;
testo(10,440,'premi return,prego');
ch:=readkey;
setcolor(1);
testo(10,440,'premi return,prego');
end;


procedure elimina1; (* cancella testo alto*)
begin
setfillstyle(1,1);
bar(1,1,650,50);
end;

procedure elimina2; (* cancella testo basso*)
begin
setfillstyle(1,1);
bar(1,350,650,440);
end;

procedure cancella; (* cancella video *)
begin
setfillstyle(1,1);
bar(1,1,650,650);
end;

procedure legenda1;
begin
settextstyle(1,0,1);
testo(10,10,'raggi incidenti');
testo(300,310,'schermo con immagine trasmessa');
testo(100,50,'raggi trasmessi dai diaframmi');
settextstyle(0,0,0);
end;

procedure fessura(colore:integer;stringa:string50);
var a,d:integer;
begin
d:=0;
legenda1;
line(100,100,400,100);(* contenitore*)
line(100,300,400,300);
setfillstyle(2,colore); (* raggi globali*)
bar(10,190,100,220);
testo(10,350,'diaframma singolo..diaframma doppio :tipo fessura ');
testo(400,360,'immagine di interferenza');
testo(10,390,stringa);
setcolor(14);
line(400,100,400,300); (* schermo*)
line(100,100,100,200); (*fenditura*)
line(100,300,100,205);
line(200,100,200,150); (* doppia fenditura*)
line(200,155,200,250);
line(200,255,200,300);
delay(1000);
setcolor(colore);
line(100,205,200,205);
testo(10,400,'raggio trasmesso e immagine singola prevedibile');
delay(1000);
for a:=1 to 21 do
begin
setcolor(colore);
line(400,100+d,480,100+d);
d:=d+10;
end;
testo(10,410,'immagine osservata:righe colorate e nere alternate');
d:=0;
for a:=1 to 21 do
begin
setcolor(colore);
line(100,205,200,100+d);
line(200,150,400,100+d);
line(200,250,400,300-d);
d:=d+10;
end;
end;

procedure bianca(colore,tipo:integer;stringa:string50);
var a,d,tinta:integer;
begin
d:=0;
legenda1;
if (tipo=1) then begin colore:=15;tinta:=2;end;
if (tipo=0) then tinta:=colore;
line(100,100,400,100);(* contenitore*)
line(100,300,400,300);
setfillstyle(2,colore); (* raggi globali*)
bar(10,190,100,220);
testo(10,350,'diaframma singolo..diaframma doppio :tipo fessura ');
testo(400,360,'immagine di interferenza');
testo(10,390,stringa);
setcolor(14);
line(400,100,400,300); (* schermo*)
line(100,100,100,200); (*fenditura*)
line(100,300,100,205);
line(200,100,200,150); (* doppia fenditura*)
line(200,155,200,250);
line(200,255,200,300);
delay(1000);
setcolor(colore);
line(100,205,200,205);
testo(10,400,'raggio trasmesso e immagine singola prevedibile');
delay(1000);
for a:=1 to 21 do
begin
setcolor(tinta);
line(400,100+d,480,100+d);
tinta:=tinta+tipo;
if (tinta>14) then tinta:=2;
d:=d+10;
end;
if (tipo=1) then testo(10,410,'immagine osservata:righe colorate alternate');
if (tipo=0) then testo(10,410,'immagine osservata:righe colorate e scure');
d:=0; tinta:=2;
for a:=1 to 21 do
begin
setcolor(tinta);
line(100,205,200,100+d);
line(200,150,400,100+d);
line(200,250,400,100+d);
d:=d+10; tinta:=tinta+tipo;
if (tinta>14 ) then tinta:=2;
end;
end;

procedure foro(colore,tipo:integer;stringa:string50);
var a,d,tinta:integer;
begin
d:=0;
legenda1;
if (tipo=1) then begin colore:=15;tinta:=2;end;
if (tipo=0) then tinta:=colore;
line(100,100,400,100);(* contenitore*)
line(100,300,400,300);
setfillstyle(2,colore); (* raggi globali*)
bar(10,190,100,220);
testo(10,350,'diaframma singolo..diaframma doppio:circolari ');
testo(400,360,'immagine di interferenza');
testo(10,390,stringa);
setcolor(14);
line(400,100,400,300); (* schermo*)
line(100,100,100,200); (*fenditura*)
line(100,300,100,205);
line(200,100,200,150); (* doppia fenditura*)
line(200,155,200,250);
line(200,255,200,300);
delay(1000);
setcolor(colore);
line(100,205,200,205);
testo(10,400,'raggio trasmesso e immagine singola prevedibile');
for a:=1 to 11 do
begin
setcolor(tinta);
circle(520,200,d);
d:=d+10; tinta:=tinta+tipo;
if (tinta>14) then tinta:=2;
end;
if (tipo=1) then testo(10,410,'immagine osservata:cerchi colorati alternati');
if (tipo=0) then testo(10,410,'immagine osservata:cerchi colorati e scuri');
d:=0; tinta:=2;
for a:=1 to 21 do
begin
setcolor(tinta);
line(100,205,200,100+d);
line(200,150,400,100+d);
line(200,250,400,100+d);
d:=d+10; tinta:=tinta+tipo;
if (tinta>14) then tinta:=2;
end;
end;


procedure forinda(colore,tipo:integer;stringa:string50);
var a,d,tinta,a1:integer;
begin
testo(10,10,'interpretazione ondulatoria');delay(1000);
d:=0;a1:=0;
if (tipo=1) then begin colore:=15;tinta:=2;end;
if (tipo=0) then tinta:=colore;
line(100,100,400,100);
line(100,300,400,300);
setfillstyle(2,colore);
bar(10,190,100,220);
testo(10,350,'diaframma singolo..diaframma doppio:circolari ');
testo(400,360,'immagine di interferenza');
testo(10,390,stringa);
setcolor(14);
line(400,100,400,300);
line(100,100,100,200);
line(100,300,100,205);
line(200,100,200,150);
line(200,155,200,250);
line(200,255,200,300);
delay(1000);
setviewport(1,100,400,300,clipon);
for a:=1 to 21 do
begin
arc(100,103,270,90,a1);
a1:=a1+5;
end;
setcolor(14);
line(200,50,200,150);
line(200,400,200,250);
line(200,152,200,248);
a1:=0;
for a:=1 to 40 do
begin
setcolor(2);
arc(205,50,270,90,a1);
setcolor(4);
arc(205,150,270,90,a1);
a1:=a1+5;
setcolor(15);
end;
delay(1000);
setcolor(colore);
line(1,105,100,105);
testo(10,400,'raggio trasmesso e immagine singola prevedibile');
for a:=1 to 11 do
begin
setcolor(tinta);
circle(520,200,d);
d:=d+10; tinta:=tinta+tipo;
if (tinta>14) then tinta:=2;
end;
if (tipo=1) then testo(10,410,'immagine osservata:cerchi colorati alternati');
if (tipo=0) then testo(10,410,'immagine osservata:cerchi colorati e scuri');
d:=0; tinta:=2;
for a:=1 to 21 do
begin
setcolor(tinta);
line(100,105,200,1+d);
line(200,50,400,1+d);
line(200,150,400,1+d);
d:=d+10; tinta:=tinta+tipo;
if (tinta>14) then tinta:=2;
end;
setviewport(0,0,650,650,clipon);
end;

procedure onda1(h,colore,g:integer;stringa:string50);
var a,x,y,s1:integer;
rad1:real;
begin
x:=10;y:=200;
testo(20,20,stringa);
setcolor(14);
line(x,y,600,y);
line(x,10,x,400);
for a:=1 to g do
begin
rad1:=a*3.14/32;
s1:=round(h*sin(rad1));
putpixel(x+a,y+s1,colore);
end;
delay(2000);elimina1;
end;

procedure piena1(h,colore,g:integer;stringa:string50);
var a,x,y,s1:integer;
rad1:real;
begin
x:=10;y:=200;
testo(20,20,stringa);
setcolor(14);
line(x,y,600,y);
line(x,10,x,400);
for a:=1 to g do
begin
setcolor(colore);
rad1:=a*3.14/32;
s1:=round(h*sin(rad1));
line(x+a,y,x+a,y+s1);
end;
delay(2000);elimina1;
end;

procedure onda2(f:integer);
var a,x,y,s1,s2,h1,h2:integer;
rad1,rad2:real;
sf:string[5];
begin
str(f,sf);
x:=10;y:=200; h1:=50;h2:=50;
testo(20,20,'onde con ampiezze uguali:fase='+sf);
testo(20,30,'risultante con ampiezza variabile con fase');
setcolor(14);
line(x,y,600,y);
line(x,10,x,400);
for a:=1 to 600 do
begin
rad1:=a*3.14/32;
rad2:=((a+f)*3.14/32);
s1:=round(h1*sin(rad1));
s2:=round(h2*sin(rad2));
putpixel(x+a,y+s1,5);
putpixel(x+a,y+s2,2);
putpixel(x+a,y+s1+s2,15);
end;
delay(2000);elimina1;
end;

procedure prova1;
begin
grafica(1);fessura(2,'luce verde');pausa1;
grafica(1);fessura(4,'luce rossa');pausa1;
grafica(1);foro(2,0,'luce verde');pausa1;
grafica(1);foro(5,1,'luce bianca');pausa1;
grafica(1);forinda(5,1,'luce bianca');pausa1;
end;

procedure prova2; (* luce bianca *)
begin
bianca(2,0,'luce verde');pausa1;
grafica(1);bianca(15,1,'luce bianca');pausa1;
end;

procedure prova3; (* interpretazione ondulatoria *)
begin
grafica(1);onda1(50,5,500,'prima radiazione:ampiezza 50');
onda1(40,2,500,'seconda radiazione:ampiezza 40');
onda1(90,14,360,'risultante radiazioni in fase:ampiezza 90');
pausa1;
grafica(1);onda1(50,5,500,'prima radiazione:ampiezza 50');
onda1(-50,2,500,'seconda radiazione:ampiezza 50');
onda1(0,15,360,'risultante radiazioni in opposizione:ampiezza 0');
pausa1;
end;

procedure prova4; (* interpretazione ondulatoria *)
begin
grafica(1);piena1(50,5,500,'prima radiazione:ampiezza 50');
piena1(40,2,500,'seconda radiazione:ampiezza 40');
piena1(90,14,360,'risultante radiazioni in fase:ampiezza 90');
pausa1;
grafica(1);piena1(50,5,500,'prima radiazione:ampiezza 50');
piena1(-50,2,500,'seconda radiazione:ampiezza 50');
piena1(0,15,360,'risultante radiazioni in opposizione:ampiezza 0');
pausa1;
end;


procedure prova5;
begin
grafica(1);onda2(45);pausa1;grafica(1);onda2(60);pausa1;
end;


procedure programma;
procedure inizio;
begin
grafica(4);
testo(50,100,'indica velocita:1=rapido...5=medio...8=lento ');read(sosta);
sosta:=sosta*1000;
end;

procedure scelta;
begin
grafica(2);
testo(10,10,'indica opzione,premendo il tasto indicato');
testo(10,40,'1..fenomeni di interferenza :immagini lineari e circolari');
testo(10,50,'2..variante della precedente');
testo(10,60,'3..generalita sulla interferenza:testo');
testo(10,70,'4..per utente');
testo(10,80,'5..per utente');
testo(10,90,'6..inizio');
testo(10,100,'7..fine operazione');
gotoxy(10,20);read(opzione);
grafica(1);
case opzione of
1:prova1;
2:prova2;
3:prova3;
4:prova4;
5:prova5;
6:inizio;
7:exit;
end;
scelta;
end;

begin
inizio;
scelta;
end;


begin (* programma principale *)
clrscr;
grafica(1);
presenta;
programma;
end.

 

 

 

 

 

 

 

vedi listato variante diffra2.html