function [ r, p_xy, p_type ] = radial_growth ( r, np, p_xy, p_type )

%*****************************************************************************80
%
%% radial_growth() simulates the radial expansion of the region.
%
%  Discussion:
%
%    On points with negative P_TYPE were just added.
%
%    The radius must be expanded so that the arc length per point ratio
%    is preserved.
%
%    All negative values of P_TYPE become positive.
%
%    All points move outward radially.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 December 2012
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real R, the radius of the circle.
%
%    integer NP, the number of points.
%
%    real P_XY(2,NP), the point coordinates.
%
%    integer P_TYPE(NP),
%    1, the point is constrained to the circle.
%    2, the point is constrainted to the disk.
%    -1, the point is a new point, constrained to the circle.
%    -2, the point is a new point, constrained to the disk.
%
%  Output:
%
%    real R, the updated radius.
%
%    real P_XY(2,NP), the updated point coordinates.
%
%    integer P_TYPE(NP), the updated types.
%

%
%  Discover the growth factor.
%
  c = find ( p_type == 1 );
  nc = length ( c );

  c_new = find ( abs ( p_type ) == 1 );
  nc_new = length ( c_new );

  factor = nc_new / nc;
%
%  Make all types positive.
%
  p_type(1:np) = abs ( p_type(1:np) );
%
%  Expand the radius and the coordinates.
%
  r = factor * r;
  p_xy(1:2,1:np) = factor * p_xy(1:2,1:np);

  return
end

  
