esercitazioni di ottica

esci otticaturbo.htm

immagini con specchi concavi

(* conca2g.fis immagini specchi concavi *)
(* immagine grafica *)

program specchi1;
uses crt,graph;
var g:real;
p,q,s,f,i:integer;
scelta,contatore,passo:integer;
x1,x2,xv,xf,xc,y,pausa: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(6);
outtextxy(x1,y+20,'asse principale ');
line(x1,y,x2,y); (* asse principale*)
outtextxy(xv,y+170,'specchio concavo');
line(xv,y-190,xv,y+190); (* specchio *)
outtextxy(xf,y+10,'fuoco');
line(xf,y+2,xf,y-2); (* fuoco *)
outtextxy(xc,y-10,'centro curvatura');
line(xc,y+2,xc,y-2); (* centro curvatura *)
end;

procedure disegna(p,q,s,i:integer);
var ps,qs,hs,hi:string;
begin
assi;
str(p,ps);
str(q,qs);
str(s,hs);
str(i,hi);
outtextxy(10,10,ps);outtextxy(50,10,'posizione sorgente');
outtextxy(10,20,qs);outtextxy(50,20,'posizione immagine');
outtextxy(10,30,hs);outtextxy(50,30,'altezza sorgente ');
outtextxy(10,40,hi);outtextxy(50,40,'altezza immagine ');
outtextxy(400,10,'distanza focale=40');
setcolor(3);
line(xv+p,y,xv+p,y-s); (* sorgente *)
setcolor(4);
line(xv+q,y,xv+q,y+i); (* immagine *)
setcolor(5);
line(xv,y-s,xv+p,y-s); (* raggio incidente parallelo asse *)
if p>f then
line(xv,y+i,xv+p,y-s) (* raggio incidente passa per fuoco *)
else
line(xc,y,xv+q,y+i); (* raggio passa per centro curvatura *)
if p>f then
line(xv,y+i,xv+q,y+i); (* raggio riflesso parallelo asse *)
if p>f then
line(xv,y-s,xv+q,y+i) (* raggio riflesso passa per fuoco *)
else
line(xf,y,xv+q,y+i);
delay(pausa);
setcolor(0);
outtextxy(10,10,ps);
outtextxy(10,20,qs);
outtextxy(10,30,hs);
outtextxy(10,40,hi);
line(xv+p,y,xv+p,y-s); (* sorgente *)
line(xv+q,y,xv+q,y+i); (* immagine *)
line(xv,y-s,xv+p,y-s); (* raggio incidente parallelo asse *)
if p>f then
line(xv,y+i,xv+p,y-s) (* raggio incidente passa per fuoco *)
else
line(xc,y,xv+q,y+i); (* raggio passa per centro curvatura *)
if p>f then
line(xv,y+i,xv+q,y+i); (* raggio riflesso parallelo asse *)
if p>f then
line(xv,y-s,xv+q,y+i) (* raggio riflesso passa per fuoco *)
else
line(xf,y,xv+q,y+i);
end;

procedure calcola;
begin
clrscr;
grafica;
f:=40;
p:=120;
s:=40;
passo:=10;
x1:=1;x2:=600;xv:=300;
xf:=xv+f;xc:=xv+2*f;
y:=200;
for contatore:=1 to 9 do
begin
if p=f then
begin
p:=p-passo;
end;
q:=round(f*p/(p-f));
g:=q/p;
i:=round(s*g);
disegna(p,q,s,i);
p:=p-10;
end;
setcolor(5);
outtextxy(10,350,'premi 1 per rivedere o 2 per finire');
readln(scelta);
if (scelta=1) then calcola else exit;
end;

begin
clrscr;
writeln('creazione immagini con specchio concavo');
writeln('si sposta la sorgente verso lo specchio');
writeln('si calcolano e si visualizzano :');
writeln('posizione sorgente,posizione immagine');
writeln('altezza sorgente costante e altezza immagine');
writeln;
writeln('indica valore per velocita:1000..2000..3000 ');
readln(pausa);
calcola;
end.