function triangle_snap_test ( )

%*****************************************************************************80
%
%% triangle_snap_test tests triangle_snap().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 November 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangle_snap_test\n' );
  fprintf ( 1, '  triangle_snap() snaps a polyiamond so that it has\n' );
  fprintf ( 1, '  minimum I and J node coordinates of 0.\n' );

  t = triangle_tiny ( );

  d = [ -3, +2 ];
  t2 = triangle_translate ( t, d );

  t3 = triangle_snap ( t2 );

  clf ( );
  hold ( 'on' );
%
%  Draw the parallelogram grid.
%
  [ imin1, imax1, jmin1, jmax1 ] = triangle_range ( t );
  [ imin2, imax2, jmin2, jmax2 ] = triangle_range ( t2 );

  imin = 0;
  imin = min ( imin, imin1 );
  imin = min ( imin, imin2 );
  imax = max ( imax1, imax2 ) + 1;

  jmin = 0;
  jmin = min ( jmin, jmin1 );
  jmin = min ( jmin, jmin2 );
  jmax = max ( jmax1, jmax2 ) + 1;

  hold ( 'on' );

  r = 0.85;
  color_back = 'cyan';
  color_tri =  'yellow';
  number = false;
  grid_plot ( imin, imax, jmin, jmax, r, color_back, color_tri, number );
%
%  Draw the polyiamonds.
%
  color = 'cyan';
  number = true;
  triangle_plot ( t, color, number );

  color = 'red';
  number = true;
  triangle_plot ( t2, color, number );

  axis ( 'equal' );
  axis ( 'off' );
  title ( 'triangle snap: cyan snapped to red' )

  hold ( 'off' );

  filename = 'triangle_snap_test.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangle_snap_test\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end

