% light wavelength
lambda=670e-9; % 670 nm - red light

% set up mask (source image)

% disk mask
Nx_s=101;
Ny_s=101;
img_source=zeros(Ny_s,Nx_s); 
xpos_s=linspace( -5.0e-3, 5.0e-3, Nx_s);
ypos_s=linspace( -5.0e-3, 5.0e-3, Ny_s);
% 
disk_R=2e-3;
[X,Y]=meshgrid(xpos_s,ypos_s);
d=sqrt(X.^2+Y.^2);
img_source(d < disk_R )=1; % set disk pixels

% set up target image
Nx_t=101;
Ny_t=101;
img_t=zeros(Ny_t,Nx_t); 
xpos_t=linspace( -5e-3, 5e-3, Nx_t);
ypos_t=linspace( -5e-3, 5e-3, Ny_t);
z_t=1.1e1;


% generating image of the mask accounting the diffraction
tic; % start timer
img_t=diffracted_image_at_target(img_source, xpos_s, ypos_s, img_t, xpos_t, ypos_t, z_t, lambda);
toc % show evaluation time

% plot source and target images
show_diffraction(img_source, xpos_s, ypos_s, img_t, xpos_t, ypos_t);
