function [TH_nx,TH_ny,XE,YE] = generate(TH_max, Probe_diam, TH_calc,Probe_calc)
% GENERATE XE,YE
if Probe_diam == 0
    X_shift = 0;
    Y_shift = 0;
else 
    if Probe_calc == 1  % uniform
        R  = mcrand;
        XE = Probe_diam*(R-0.5)*2;
        R  = mcrand;
        YE = sqrt(Probe_diam^2-XE^2)*(R-0.5)*2;
    else % ???
    end
end

% GENERATE XE, YE


% % GENERATE Th_n
% if TH_max == 0
%    TH_n = 0;
% else 
%    R = mcrand; 
%    if TH_max==1,
%          TH_n = TH_max*sqrt(R);
%    elseif TH_max~=0,
%          TH_n = TH_max*R;
%    end
% end 

%GENERATE TH_nx
if TH_max == 0
   TH_nx = 0;
else
    if TH_calc == 1 % uniform  <0,1>
        Rsign = round(rand(1));  % urci znamienko +/- - natocenie zvazku 
        R = rand(1); 
        while R==0
            R = rand(1);
        end
        
        if TH_max==1,
            if Rsign == 0  % pozitivny smer
               TH_nx = TH_max*sqrt(R);
            else % Rsign == 1
               TH_nx = 0 - TH_max*sqrt(R);
            end
        elseif TH_max~=0,
            if Rsign == 0  % pozitivny smer
               TH_nx = TH_max*R;
            else
                TH_nx = 0 - TH_max*R;
            end
        end
        
    elseif TH_calc == 0  % ine rozlozenie - normal?  <-,+>
    end    
end


%GENERATE TH_ny
if TH_max == 0
   TH_ny = 0;
else
    if TH_calc == 1 % uniform  <0,1>
        Rsign = round(rand(1));  % urci znamienko +/- - natocenie zvazku
        R = rand(1); 
        while R==0
            R = rand(1);
        end
        
        if TH_max==1,
            if Rsign == 0  % pozitivny smer
               TH_ny = TH_max*sqrt(R);
            else % Rsign == 1
               TH_ny = 0 - TH_max*sqrt(R);
            end
        elseif TH_max~=0,
            if Rsign == 0  % pozitivny smer
               TH_ny = TH_max*R;
            else
                TH_ny = 0 - TH_max*R;
            end
        end
        
    elseif TH_calc == 0  % ine rozlozenie - normal?  <-,+>
    end    
end