%
%
%
% Fresnel diffraction
%
%
%
%
close all; clear all;
figure(1);set(gcf,'color','white');
X=1000; %microns
lambda=1; %micron
N=1024; % samples per axis
xrange=linspace(-X,X,N);
urange=(-N/(4*X)):(1/(2*X)):(N/2-1)/(2*X);
[x,y]=meshgrid(xrange);
[u,v]=meshgrid(urange);
%
% input pattern consists of Gaussian spots of radius 20-250 microns
%
f=exp(-pi*(x.^2+y.^2)/20^2);
f=f+exp(-pi*((x-100).^2+y.^2)/50^2);
f=f+exp(-pi*((x+200).^2+y.^2)/100^2);
f=f+exp(-pi*(x.^2+(y-200).^2)/250^2);
subplot(2,2,1);imagesc(xrange,xrange,f);colormap 'gray';axis 'square';title('f(x,y)');
d=500; % microns
fresnelT=exp(i*pi*d*lambda*(u.^2+v.^2));
ft=ifft2(fftshift(fresnelT).*fft2(f));
subplot(2,2,2);imagesc(xrange,xrange,abs(ft));colormap 'gray';axis 'square';title('d= 500 microns');
d=1000; % microns
fresnelT=exp(i*pi*d*lambda*(u.^2+v.^2));
ft=ifft2(fftshift(fresnelT).*fft2(f));
subplot(2,2,3);imagesc(xrange,xrange,abs(ft));colormap 'gray';axis 'square';title('d=1 mm');
d=10000; % microns
fresnelT=exp(i*pi*d*lambda*(u.^2+v.^2));
ft=ifft2(fftshift(fresnelT).*fft2(f));
subplot(2,2,4);imagesc(xrange,xrange,abs(ft));colormap 'gray';axis 'square';title('d=10 mm');




