function [ w2, p2 ] = boundary_snap ( w, p )

%*****************************************************************************80
%
%% boundary_snap() "snaps" a polyiamond described by its boundary word.
%
%  Discussion:
%
%    We "snap" a polyiamond by translating it so that its least I and
%    least J node coordinates are 0.
%
%    The boundary word describes how to trace the boundary by starting
%    at a base point (i,j), and taking a sequence of steps of unit length 
%    in one of 6 directions, as suggested by this diagram:
%
%          5-----0-----*
%      ^  / \   / \   /
%     /  /   \ /   \ /
%    J  4-----P-----1
%      / \   / \   /
%     /   \ /   \ /
%    *-----3-----2
%
%          I-->
%
%    If the current position P has parallelogram coordinates (I,J), then
%    the step of given index moves to
%
%      0  (I,  J+1)
%      1  (I+1,J  )
%      2  (I+1,J-1)
%      3  (I,  J-1)
%      4  (I-1,J  )
%      5  (I-1,J+1)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string W: the boundary word.  
%
%    integer P(1,2): the boundary word starting point.
%
%  Output:
%
%    string W2: the boundary word for the snapped polyiamond.  
%
%    integer P2(1,2): the boundary word starting point for the 
%    snapped polyiamond.
%
  [ imin, imax, jmin, jmax ] = boundary_range ( w, p );

  w2 = w;
  p2 = [ p(1) - imin, p(2) - jmin ];

  return
end

