function x = disk_sample ( r, n )

%*****************************************************************************80
%
%% disk_sample() uniformly samples a disk centered at the origin.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    04 November 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real r: the radius of the disk.
%
%    integer n: the number of sample points.
%
%  Output:
%
%    real x(n,2): the points.
%
% rng ( 'shuffle' );
%
%  Get random points on the circumference of the unit circle.
%
  x = randn ( n, 2 );
  xnorm = ( x.^2 ) * ones ( 2, 1 );
  xnorm = sqrt ( xnorm );
  for j = 1 : 2
    x(1:n,j) = x(1:n,j) ./ xnorm(1:n);
  end
%
%  Randomly shrink these points into the unit circle.
%
  for i = 1 : n
    s = rand ( 1, 1 );
    x(i,1:2) = sqrt ( s ) * x(i,1:2);
  end
%
%  Rescale to the circle of radius R.
%
  x = r * x;

  return
end

