%LightPipes Simulation with LightPipes for Matlab
%February 2014. F.A. van Goor.
%Matlab_intrf_newtonrings.m
%Newton rings interference example.

clear all;

m=1;
nm=1e-9*m;
mm=1e-3*m;
cm=1e-2*m;

lambda=500*nm; %wavelength
size=5*mm;
N=200;
R=3*m; %radius positive lens
nf=1.5; %refractive index film

deltaPhi=ones(N,N);
k=2*pi/lambda; %propagation constant
F1=LPBegin(size,lambda,N); %make plane wave
%phase reflected from lens:
for i=1:N
    x=-size/2+i*size/N;
    for j=1:N 
        y=-size/2+j*size/N;
        deltaPhi(i,j)=2*nf*k*(x*x+y*y)/(2*R)+pi; 
    end
end
F1=LPSubPhase(deltaPhi,F1); %field after internal reflection at lens surface
F2=LPBegin(size,lambda,N); %field after reflection from flat glass plate
F=LPBeamMix(F2,F1); %combine the two fields
I=LPIntensity(2,F); %intensity
imagesc(I); %plot intensity
axis off equal;colormap(gray);