esercitazioni di ottica

esci otticaturbo.htm

immagini con lenti divergenti

(* lented2g.fis immagini lenti divergenti *)
(* immagine grafica *)

program lente1;
uses crt,graph;
var g:real;
p,q,s,i,f:integer;
scelta,contatore,passo:integer;
x1,x2,xv,xf,y,xc,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,'lente divergente');
line(xv,y-190,xv,y+190); (* lente *)
outtextxy(xf,y+10,'fuoco');
line(xf,y+2,xf,y-2); (* fuoco *)
line(xv-f,y+2,xv-f,y-2); (* fuoco *)
outtextxy(xv+5*f,y-10,'centro curvatura');
line(xc,y+2,xc,y-2); (* centro curvatura *)
line(xv-2*f,y+2,xv-2*f,y-2);
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 *)
line(xv+p,y-s,xv-p,y+s); (* raggio incidente passa per centro ottico *)
line(xv,y-s,xv-f,y); (* raggio rifratto passa per fuoco *)
line(xv,y-s,xv+f,y-2*s);
delay(pausa);
setcolor(0);
outtextxy(10,10,ps);
outtextxy(10,20,qs);
outtextxy(10,30,hs);
outtextxy(10,40,hi);
line(xv,y-s,xv+f,y-2*s);
line(xv+p,y,xv+p,y-s);
line(xv-q,y,xv-q,y+i);
line(xv,y-s,xv+p,y-s);
line(xv+p,y-s,xv-p,y+s);
line(xv,y-s,xv-f,y);
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 lente divergente');
writeln('si sposta la sorgente verso la lente');
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.