function [F12, A1, F21, A2] = plate2cyl(H, W, L, r)
%[F12, A1, F21, A2] = plate2cyl(H, W, L, r);
%
%  Description:
%
%    View factor from rectangular plate to finite cylinder.
%
%  Inputs:
%
%    H = height of cylinder centerline above the plate
%    W = plate width
%    L = plate (and cylinder) length
%    r = cylinder radius
%
%  Outputs:
%
%    A1  = plate surface area
%    F12 = plate to cylinder view factor
%    A2  = cylinder surface area
%    F21 = cylinder to plate view factor
%
%  Reference:
%
%    E. M. Sparrow and R. D. Cess, "Radiation Heat Transfer," Hemisphere
%      Publishing, Washington, 1978, augmented edition, pp. 339-349.
%
%    H. Leuenberger and R. A. Pearson, "Compilation of radiation shape
%      factors for cylindrical assemblies." ASME Annual Meeting, New York,
%      ASME Paper No. 56-A-144, 1956
%
%==========================================================================

if r > H
  error('plate2cyl: cylinder radius = %g, is greater than distance to plate = %g.\n',r,H);
end

A1 = W*L;         %  plate surface area
A2 = 2*pi*r*L;    %  cylinder surface area

X = H/r;
Y = W/r;
Z = L/r;

F12 = (2/Y)*integral(@(zeta) fun(zeta,X,Y,Z), 0, Y/2);

F21 = (A1*F12)/A2;

end

function f = fun(zeta, X, Y, Z)
for i=1:length(zeta)
  A = Z^2 + X^2 + zeta(i)^2 - 1;
  B = Z^2 - X^2 - zeta(i)^2 + 1;
  f(i) = X/(X^2 + zeta(i)^2) -  ...
         (X/(pi*(X^2 + zeta(i)^2)))*(acos(B/A) -  ...
         (1/(2*Z))*(sqrt(A^2 + 4*Z^2)*acos(B/(A*sqrt(X^2 + zeta(i)^2))) ...
                    + B*asin(1/sqrt(X^2 + zeta(i)^2)) - (pi*A)/2));
end             
end