diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-05-19 17:14:53 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-05-19 17:14:53 -0400 |
commit | 240d1de52762c64e5dc6c981780b2320bfd191e4 (patch) | |
tree | 246540d25a05feb8e28bc3753fd32c93cc52796c /beam_field_at_point_from_image.m | |
parent | 2f4092a06c4e43218480f4d519b79454c5e64e40 (diff) | |
download | beam_reshape-240d1de52762c64e5dc6c981780b2320bfd191e4.tar.gz beam_reshape-240d1de52762c64e5dc6c981780b2320bfd191e4.zip |
added field calculation for diffracted image
Diffstat (limited to 'beam_field_at_point_from_image.m')
-rw-r--r-- | beam_field_at_point_from_image.m | 35 |
1 files changed, 35 insertions, 0 deletions
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); + |