function [R,T,Rl,Rr,Tl,Tr]=fresn(nr,ni,Teta);
% to compute the Fresnel's coefficient of reflection (see for
% example M. Born and E. Wolf, Principles of Optics, Pergamon Press, fifth
% edition, 1975, pp 628
% input parameters: nr=refractive index
%                   ni=refractive index
%                   Teta [deg]- angle of the incident radiation 
%                                   with respect of the wave facet normal.
% output parameter: R=Fresnel's coefficient for reflection

  sinchi=sin(Teta*pi/180);
  a1=nr.^2-ni.^2+sinchi.^2;
  a2=sqrt((nr.^2-ni.^2-sinchi.^2)^2.+4*nr.^2.*ni.^2);
  N=sqrt(2)/2*sqrt(a1+a2);
  sincht=sinchi/N;
  coschi=sqrt(1-sinchi.^2);
  coscht=sqrt(1-sincht.^2);
  Rl=(N*coschi-coscht)/(N*coschi+coscht);
  Rr=(coschi-N*coscht)/(coschi+N*coscht);
  Tl=2*coschi/(N*coschi+coscht);
  Tr=2*coschi/(coschi+N*coscht);
  R1=abs(Rl);
  R2=abs(Rr);
  R=(R1.^2+R2.^2)/2;  
  T1=abs(Tl)
  T2=abs(Tr)
  T=(T1.^2+T2.^2)/2;
 %keyboard