function [total, specular, volume] = hagfors(x,diel,s,A)
%Input parameters:
%   eta = scattering albedo, see Swift et al. 1999 "Seasat Scatterometer
%   Observations...
%   diel = dielectric constant
%   s = rms slope (radians)
%   theta = incidence angle (radians)

if x >= pi/2
    specular = NaN;
    total = NaN;
    return
end

ref = ((1 - sqrt(diel))/(1 + sqrt(diel)))^2; %Fresnel reflection coefficient
C = 1./(s.^2); %width parameter
%volume = ((1-ref)^2) * (eta/2) * cos(theta); %volume scatter Swift 1999
volume = volume_scatter(A, x);
specular = ((ref.*C) ./ 2) .* ((((cos(x).^4) + C.*(sin(x).^2))).^(-3/2)); %hagfors law
total = specular + volume;

end

