From 240d1de52762c64e5dc6c981780b2320bfd191e4 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Mon, 19 May 2014 17:14:53 -0400 Subject: added field calculation for diffracted image --- beam_field_at_point_from_image.m | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 beam_field_at_point_from_image.m (limited to 'beam_field_at_point_from_image.m') diff --git a/beam_field_at_point_from_image.m b/beam_field_at_point_from_image.m new file mode 100644 index 0000000..8cd4f50 --- /dev/null +++ b/beam_field_at_point_from_image.m @@ -0,0 +1,35 @@ +function E_tot=beam_field_at_point_from_image(x,y,z, img, xpos, ypos, lambda) + +[Ny,Nx] = size(img); + +xim=linspace(xpos(1), xpos(end), Nx); +yim=linspace(ypos(1), ypos(end), Ny); + +[ind_x, ind_y] = meshgrid(1:Nx, 1:Ny); +[rvec_x, rvec_y] = meshgrid(xim-x, yim-y); % rvec_x and rvec_y are matrices of Ny x Nx +rvec_z=z+rvec_x*0; % to get same matrix size as rvec_x and rvec_y + +dist=sqrt(rvec_x.^2+rvec_y.^2+rvec_z.^2); + + +E_ampl = img ./dist .* exp(1i*2*pi.*dist./lambda); + +% simple case: far field - Fraunhofer limit + +E_tot= (sum(E_ampl(:))); +%intensity = E_tot*conj(E_tot); + +%%%% Below is exact case: Fresnel diffraction +%kvec_x= rvec_x./dist; +%kvec_y= rvec_y./dist; +%kvec_z= rvec_z./dist; +% +%Ex= E_ampl * kvec_x; +%Ey= E_ampl * kvec_y; +%Ez= E_ampl * kvec_z; +%% summing all E field components +%Ex_tot = sum (Ex(:)); +%Ey_tot = sum (Ey(:)); +%Ez_tot = sum (Ez(:)); +%intensity = Ex_tot*conj(Ex_tot) + Ey_tot*conj(Ey_tot) + Ez_tot*conj(Ez_tot); + -- cgit v1.2.3