
%Purpose: propagation of the wave by using the Angular Spectrum Method
%'Inputs': 'Comp_Amp0',the input complex amplitude of the object wave;
         %'d', propagation distance('m');  
         %'Pixel', pixel size of input object wave;
%'Outputs': 'Comp_Amp,Complex amplitude of the propagated object wave; 
            %'H', Propagation core to check the correctness of the method;


function [Comp_Amp,H]=Angular_Spectrum_Propagation(Comp_Amp0,d,lambda,Pixel)
    
    k=2*pi/lambda; %Wave vector;
    
   %Coordinates in Fourier plane;
    [y_length,x_length]=size(Comp_Amp0); %The size of interferogram;
    u=(-x_length/2:x_length/2-1)*(1/Pixel/x_length); %Spectrum coordinate;
    v=(-y_length/2:y_length/2-1)*(1/Pixel/y_length); %Spectrum coordinate;
    [uu,vv]=meshgrid(u,v); %Two dimensional frequency (Unit: 1/m);
    
   %Propagation with ASP:
    Freq=fftshift( fft2(fftshift(Comp_Amp0)) );  %Frequency spectrum;
    H=exp(1i*k*d*sqrt( abs(1-(lambda*uu).^2-(lambda*vv).^2 ))); %Wave function for plane wave (uu,vv); %%-->Note: h only relys on the piexl size of image; 
    Comp_Amp=fftshift( ifft2(fftshift(Freq.*H)) );  %Reconstructed object wave;        
  
end

%Note: the units of the inputs can be 'm' or 'mm';