function circle_scatters ( )

%*****************************************************************************80
%
%% CIRCLE_SCATTERS plots data in and out of a circle.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    19 July 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'CIRCLE_SCATTERS:\n' );
  fprintf ( 1, '  Octave version\n' );
  fprintf ( 1, '  Make scatter plots of two sets of data representing\n' );
  fprintf ( 1, '  points inside, and points outside the unit circle.\n' );
%
%  Read the data.
%
  xy_in = load ( 'circle1_data.txt' );
  [ n_in, dim ] = size ( xy_in );

  xy_out = load ( 'circle2_data.txt' );
  [ n_out, dim ] = size ( xy_out );

  n = n_in + n_out;
%
%  Report on the estimate for pi:
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of points inside the circle = %d\n', n_in );
  fprintf ( 1, '  Number outside                     = %d\n', n_out );
  fprintf ( 1, '  Total                              = %d\n', n );
  fprintf ( 1, '  Estimate for PI                    = %d\n', 4 * n_in / n );
%
%  Set up points on a circle
%
  n = 50;
  center = [ 0.0, 0.0 ];
  radius = 1.0;
  theta1 = 0.0;
  theta2 = 90.0;

  xy_circ = circle_arc ( n, center, radius, theta1, theta2 );
%
%  Plot the data.
%
  clf
  hold on
    plot ( xy_in(:,1),  xy_in(:,2),  'b.', 'Markersize', 20 )
    plot ( xy_out(:,1), xy_out(:,2), 'r.', 'Markersize', 20 )
    plot ( xy_circ(:,1), xy_circ(:,2), 'r-', 'LineWidth', 2 );
  hold off

  grid on
  axis ( [ 0.0, 1.0, 0.0, 1.0 ] )
  axis equal
  axis square
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'Random points inside/outside the unit circle' );

  pause ( 5 )
%
%  Save the plot as a PNG file.
%
  filename = 'circle_scatters.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphic data saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'CIRCLE_SCATTERS:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
function xy_circ = circle_arc ( n, center, radius, theta1, theta2 )

%*****************************************************************************80
%
%% CIRCLE_ARC samples points on a circular arc.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    23 April 2011
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the number of sample points.
%
%    Input, real CENTER(2), the center of the circle.
%
%    Input, real RADIUS, the radius of the circle.
%
%    Input, real THETA1, THETA2, the angular coordinates of the first and
%    last points on the arc, in degrees.
%
%    Output, real XY_CIRC(N,2), points along the arc.
%
  t = pi * linspace ( theta1, theta2, n ) / 180;
  t = t';

  xy_circ = zeros ( n, 2 );

  xy_circ(:,1) = center(1) + radius * cos ( t(:,1) );
  xy_circ(:,2) = center(2) + radius * sin ( t(:,1) );

  return
end
