esercitazioni di ottica

esci otticaturbo.htm

immagini con rifrazione

(* rifra3g.fis indice di rifrazione con grafica e angolo limite*)

program rifra3g;
uses crt,graph;
var i,r,n:real;
a,si,sr,ci,cr,tr:real;
scelta,pausa,contatore,passo,x,x1,x2,y,ai,ar:integer;

procedure grafica;
var sc,tp:integer;
stringa:string;
begin
sc:=0;
tp:=0;
stringa:='c:\tp\bgi';
initgraph(sc,tp,stringa);
end;

procedure assi;
begin
setcolor(5);
outtextxy(10,10,'mezzo meno rifrangente');
outtextxy(10,340,'mezzo piu rifrangente');
line(x1,y,x2,y); (* passaggio da meno a piu rifrangente *)
line(x,y-150,x,y+150); (* normale *)
end;

procedure fine;
begin
outtextxy(10,350,'fine:arrivederci:premi enter');
readln;
closegraph;textmode(0);
end;

procedure disegna(si,ci,sr,cr:real);
var h:integer;
ai,ar,ax:string;
begin
h:=100;
str(round(i),ai);
str(round(r),ar);
assi;
setcolor(4);
if (i<40) then
begin
outtextxy(10,40,ai);outtextxy(50,40,'angolo di incidenza');
outtextxy(10,50,ar);outtextxy(50,50,'angolo di rifrazione');
outtextxy(50,60,'indice di rifrazione= 1 / 1.55');
setcolor(4);
line(x,y,x-round(h*sr),y-round(h*cr));(* rifratto *)
line(x,y,x+round(h*si),y+round(h*ci)); (* incidente *)
delay(pausa);
if (i=39) then
begin
outtextxy(300,300,'incidente quasi angolo limite');
delay(3000);
end;
setcolor(0);
outtextxy(10,40,ai);
outtextxy(10,50,ar);
outtextxy(300,300,'incidente quasi angolo limite');
line(x,y,x+round(h*si),y+round(h*ci));(* rifratto *)
line(x,y,x-round(h*sr),y-round(h*cr));(* incidente *)
end;

if (i>40) then
begin
str(round(i),ax);
outtextxy(300,150,'riflessione totale');
outtextxy(10,300,ax);outtextxy(400,300,'angolo incidente');
outtextxy(10,310,ax);outtextxy(400,310,'angolo riflessione');
line(x,y,x+round(h*si),y+round(h*ci));
line(x,y,x-round(h*si),y+round(h*ci));
delay(pausa);
if(i=70) then delay(5000);
setcolor(0);
line(x,y,x+round(h*si),y+round(h*ci));
line(x,y,x-round(h*si),y+round(h*ci));
outtextxy(10,300,ax);
outtextxy(10,310,ax);
end;
end;

procedure calcola;
begin
clrscr;
grafica;
n:=1/1.55;
passo:=1;
i:=1;
for contatore:=1 to 70 do
begin
if i<=40 then
begin
si:=sin(i*3.14/180);
ci:=cos(i*3.14/180);
sr:=si/n;
cr:=sqrt(1-sqr(sr));
tr:=sr/cr;
r:=arctan(tr)*180/3.14;
disegna(si,ci,sr,cr);
i:=i+passo;
end
else
begin;
r:=i;
si:=sin(i*3.14/180);
ci:=cos(i*3.14/180);
disegna(si,ci,0,0);
i:=i+passo;
end;
end;
setcolor(5);assi;
outtextxy(10,230,'premi enter');
outtextxy(10,250,'premi 1 per rivedere o 2 per finire');
readln(scelta);
if (scelta=1) then calcola else fine;
end;

begin
clrscr;
writeln('leggi della rifrazione:da vetro ad aria ');
writeln('angolo limite e riflessione totale ');
writeln('indica valore per pausa:100..1000...2000.3000..');
readln(pausa);
x1:=1;x2:=600;x:=300;y:=200;
calcola;
end.