function segment = p06_boundary_segment ( segment_index, m, segment_length )

%*****************************************************************************80
%
%% p06_boundary_segment returns a boundary segment in problem 06.
%
%  Discussion:
%
%    The points are not uniformly spaced.  However, they correspond
%    to a uniform angular spacing.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 April 2009
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Per-Olof Persson and Gilbert Strang,
%    A Simple Mesh Generator in MATLAB,
%    SIAM Review,
%    Volume 46, Number 2, June 2004, pages 329-345.
%
%  Input:
%
%    integer SEGMENT_INDEX, the index of the boundary segment.
%
%    integer M, the spatial dimension.
%
%    integer SEGMENT_length, the number of points in the segment.
%
%  Output:
%
%    SEGMENT(M,SEGMENT_length), points on the boundary segment.
%
  center = [ 0.0, 0.0 ];
  r1 = 1.0;
  r2 = 0.5;

  if ( segment_index == 1 )
    r = r1;
  elseif ( segment_index == 2 )
    r = r2;
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, 'P06_boundary_segment - Fatal error!\n' );
    fprintf ( 1, '  Illegal SEGMENT_INDEX = %d\n', segment_index );
    error ( 'P06_boundary_segment - Fatal error!' );
  end

  for j = 1 : segment_length

    angle = ( 2.0 * pi * ( j - 1 ) ) / ( segment_length - 1 );
    x = r * cos ( angle );
    y = r * sin ( angle );

    alpha = ( r^4 / ( x^4 + y^4 ) )^0.25;

    segment(1,j) = center(1) + alpha * x;
    segment(2,j) = center(2) + alpha * y;
  
  end

  return
end
