function [ zc, zs ] = spherical_harmonic_angle_table ( l, m, theta_num, phi_num )

%*****************************************************************************80
%
%% spherical_harmonic_angle_table() tabulates a spherical harmonic over angles.
%
%  Discussion:
%
%    This function produces a table of the spherical harmonic 
%    function Y(l,m,theta,phi) over a range of angular values of theta and phi.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 March 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer L, M, the indices of the spherical harmonic.
%
%    integer THETA_NUM, PHI_NUM, the number of values of THETA
%    and PHI to be used to construct the evaluation grid.
%
%  Output:
%
%    real ZC(THETA_NUM,PHI_NUM), ZS(THETA_NUM,PHI_NUM), the
%    table of components of the harmonic function.
%
  phi_min = 0.0;
  phi_max = pi;
  theta_min = 0.0;
  theta_max = 2 * pi;

  zc = zeros ( theta_num, phi_num );
  zs = zeros ( theta_num, phi_num );

  for j = 1 : phi_num

    phi = ( ( phi_num - j     ) * phi_min ...
          + (           j - 1 ) * phi_max ) ...
          / ( phi_num     - 1 );

    for i = 1 : theta_num

      theta = ( ( theta_num - i     ) * theta_min ...
              + (             i - 1 ) * theta_max ) ...
              / ( theta_num     - 1 );

      [ a, b ] = spherical_harmonic ( l, m, phi, theta );
      zc(i,j) = a(l+1);
      zs(i,j) = b(l+1);

    end
  end

  return
end
