function [ w2, p2 ] = word_rotate ( w, p, r )

%*****************************************************************************80
%
%% word_rotate() returns the boundary word for a rotated object.
%
%  Discussion:
%
%    The rotation is done about the base point.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 December 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    character vector W: the boundary word.
%
%    integer P(1,2): the coordinates of the base point.
%
%    integer R: the number of 45 degree rotations.  0 <= R < 8.
%
%  Output:
%
%    character vector W2: the boundary word of the rotated object.
%
%    integer P2(1,2): the the base point of the rotated object.
%
  p2(1,1:2) = p(1,1:2);
%
%  Advance each character by R positions, wrapping around at the end.
%
  wn = length ( w );
  w2 = '';

  r = i4_wrap ( r, 0, 4 );

  for wi = 1 : wn
    c = w(wi);
    cr = c + 2 * r;
    ci = ch_wrap ( cr, 'A', 'H' );
    w2 = [ w2, ci ];
  end
  
  return
end

