function [F12, A1, F21, A2] = orthoplate2plate(w, h, l)
%[F12, A1, F21, A2] = orthoplate2plate(w, h, l)
%
%  Description:
%
%    View factor between two orthogonal rectangular surfaces.
%
%  Inputs:
%
%    w = width of base rectangle surface
%    h = height of orthoganal rectangular surface
%    l = depth of rectangle surfaces
%
%  Outputs:
%
%    F12 = view factor from lower rectangle to vertical rectangle
%    A1  = area of the lower rectangle
%    F21 = view factor from vertical rectangle to lower rectangle
%    A2  = area of the upper rectangle
%
%  Reference:
%
%    A Catalog of Radiation Heat Transfer Configuration Factors,
%    third edition, John R. Howell, The University of Texas at Austin
%    C-14: Two finite rectangles of same length, having one common edge, 
%          and at an angle of 90o to each other.
%    http://www.thermalradiation.net/sectionc/C-14.html
%
%==========================================================================

if l <= 0.0
  error('FATAL ERROR in orthoplate2plate: depth of the plates, l = %d, must be greater than zero.',l)
end

A1 = w*l;  %  lower plate area
A2 = h*l;  %  vertical plate area

H = h/l;
W = w/l;

F12 = (1/(pi*W))*(W*atan(1/W) - sqrt(H^2 + W^2)*atan(sqrt(1/(H^2 + W^2)))  ...
      + H*atan(1/H) + (1/4)*log((((1 + W^2)*(1 + H^2))/(1 + W^2 + H^2))  ...
      *((W^2*(1 + W^2 + H^2)/((1 + W^2)*(W^2 + H^2)))^(W^2))  ...
      *((H^2*(1 + W^2 + H^2)/((1 + H^2)*(W^2 + H^2)))^(H^2))));

F21 = F12*A1/A2;  %  F12*A1 = F21*A2
