function [ x, y ] = boundary_word_boundary ( s )

%*****************************************************************************80
%
%% boundary_word_boundary(): boundary of a shape defined by a boundary word.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 May 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    char s(n): a string of the characters 'u', 'd', 'l' and 'r' that should
%    represent a path around the boundary of a shape.
%
%  Output:
%
%    integer X(n+1), Y(n+1): the coordinates of the boundary curve.
%
  check = boundary_word_check ( s );
  if ( ~ check )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'boundary_word_boundary - Fatal error!\n' );
    fprintf ( 1, '  Input boundary word "%s" is illegal.\n', s );
    return
  end

  s = lower ( s );
  s_len = length ( s );
  x = zeros(s_len + 1,1);
  y = zeros(s_len + 1,1);

  x(1) = 0;
  y(1) = 0;
  for i = 1: s_len

    if ( s(i) == 'r' )
      x(i+1) = x(i) + 1;
      y(i+1) = y(i);
    elseif ( s(i) == 'l' )
      x(i+1) = x(i) - 1;
      y(i+1) = y(i);
    elseif ( s(i) == 'u' )
      x(i+1) = x(i);
      y(i+1) = y(i) + 1;
    elseif ( s(i) == 'd' )
      x(i+1) = x(i);
      y(i+1) = y(i) - 1;
    end
  end

  return
end

