% Author Suresh kumar Devanathan
% GNU License
clear
% screen 

s_x = 600;
s_y = 600;
Screen = zeros(s_x,s_y);

% radial momentum 
avg_r  =  50;
std_r  =   2;
avg_th =   0;
std_th =   5*pi/180;

rput = 1:(s_x*s_y);

% experiments
N = 60;
Nexp = 1000;
Nrep = 200;

sang = 0;
sr   = 200;

for i = 1:Nrep
       
ang  = cumsum(avg_th + std_th * randn(Nexp,N), 2) ;
r    = cumsum(avg_r  + std_r  * randn(Nexp,N), 2) ;

screen_x =  r .* cos(ang) ;
screen_y =  r .* sin(ang) +sr *(mod(i,2) - 0.5) ; 
%screen_y =  r .* sin(ang) + repmat( sr*(rand(Nexp,1) - 0.5), 1,N);

screen_x  = screen_x(:);
screen_y = screen_y(:);

     
loc_y = round((screen_y + 1000) * s_y/2000);
loc_x = round((screen_x + 50) *  s_x/2000) ;


loc_mask =  (loc_x > 0) & (loc_x < s_x) &  (loc_y > 0) & (loc_y < s_y);
loc = nonzeros( loc_mask  .* (loc_x * s_y   + loc_y));

loc_up = histc( loc' ,  rput);


Screen( rput ) = Screen( rput )  + loc_up;

end;

% non zero db graph
imagesc(log(Screen+1));
