function uniform_on_sphere_patch_tp_test ( )

%*****************************************************************************80
%
%% uniform_on_sphere_patch_tp_test() tests uniform_on_sphere_patch_tp().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 April 2022
%
%  Author:
%
%    John Burkardt
%
  n = 500;

  phi1 =    80.0 * ( pi / 180.0 );
  phi2 =   100.0 * ( pi / 180.0 );
  theta1 =   0.0 * ( pi / 180.0 );
  theta2 = 360.0 * ( pi / 180.0 );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'uniform_on_sphere_patch_tp_test():\n' );
  fprintf ( 1, '  uniform_on_sphere_patch_tp() maps uniform\n' );
  fprintf ( 1, '  points onto a TP (THETA,PHI) patch of the unit sphere.\n' );
  fprintf ( 1, '  The points are returned as (X,Y,Z) coordinates.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of points N =          %12d\n', n );
  fprintf ( 1, '  Latitudinal angle PHI1 =      %12f\n', phi1 );
  fprintf ( 1, '  Latitudinal angle PHI2 =      %12f\n', phi2 );
  fprintf ( 1, '  Longitudinal angle THETA1 =   %12f\n', theta1 );
  fprintf ( 1, '  Longitudinal angle THETA2 =   %12f\n', theta2 );

  p = uniform_on_sphere_patch_tp ( n, phi1, phi2, theta1, theta2 );
%
%  Make a plot.
%
  clf ( );
  scatter3 ( p(:,1), p(:,2), p(:,3), 'b', 'filled' );
  grid ( 'on' );
  axis ( 'equal' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  zlabel ( '<--- Z --->' );
  title ( 'uniform\_on\_sphere\_patch\_tp()' );
  filename = 'uniform_on_sphere_patch_tp.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s".\n', filename );

  return
end
