]> Creatis software - CreaPhase.git/blob - utilities_LW/ssquare2.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / ssquare2.m
1 %# ssq=ssquare2(beta,f,g) returns sin(pi*beta*(f^2+g^2))
2 %# beta is equal to lambda*D/l^2, i.e. the Fresnelnumber
3 %# for the complete spectrum (from 0 to fsample)
4 %# f_isall = 0
5 %# only f and g from 0 to fsample/2 should be given, the other part is 
6 %# calculated using the periodicity in frequency-space
7 %# f_isall = 1
8 %# complete frequency range is given
9 %# allows for astigmatism (5th argument)
10
11 function ssq=ssquare2(betah,f,g,varargin)
12
13 f_isall = 0;
14 switch nargin
15 case 3
16     betav = betah;
17 case 4
18     f_isall = varargin{1};
19     betav = betah;
20 case 5
21     f_isall = varargin{1};
22     betav = varargin{2};
23 end 
24
25 ssq=sin((pi*betah)*f.^2+(pi*betav)*g.^2);
26
27 if (f_isall~=1)
28     [n m]=size(f);
29     n=n-1;
30     m=m-1;
31     ssq=cat(2,cat(1,ssq,flipdim(ssq(2:n,:,:),1)),cat(1,flipdim(ssq(:,2:m,:),2),flipdim(flipdim(ssq(2:n,2:m,:),1),2)));
32 end
33
34 end