function [FB_Greensfunc] = FB_Greensfunction(mesh,K,pointsource,curve,alpha)

% Aim: Compute the periodized version of the FB transform of the Greens function
% FB(u^s) = -FB(u^i)

 FB_Greensfunc = cell(1,alpha.number);
    
 
 for j = 1:alpha.number
    
  
    FB_Greensfunc{j} = zeros(1,mesh.numberpoints);
    
    for l = -20:20
        
        SQ = sqrt(K^2 - (l + alpha.nodes(j)).^2);
        
        argument = angle(SQ);
        
        % Consider the branch cuts for the square root function
        if argument < -pi/4 || argument > 0.75*pi
            SQ = -SQ;
        end
        
        FB_Greensfunc{j} = FB_Greensfunc{j} - (1/(2*pi))...
             * exp( 1i * l .* mesh.points(1,:) )...
            .* exp(-1i * (l + alpha.nodes(j) ).* pointsource(1))...
            .* exp( 1i * SQ * curve.psi(mesh.points(1,:),mesh.points(2,:))) ...
            .* pointsource(2) .* sinc( SQ .* pointsource(2));
       
        
    end
    
    
    
end
    
end





