function polygon_grid_points_test02 ( )

%*****************************************************************************80
%
%% polygon_grid_points_test02() tests polygon_grid_points().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    26 April 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polygon_grid_points_test02():\n' );
  fprintf ( 1, '  polygon_grid_points() returns grid points for a polygon\n' );
  fprintf ( 1, '  of NV vertices, with N+1 points on a side\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  For this test, the polygon is a convex quadrilateral\n' );
  fprintf ( 1, '  with sides of varying length.\n' );
%
%  Define the polygon.
%
  nv = 4;
  v = [ ...
    1.0, 1.0;
    2.0, 0.0;
    4.0, 3.0;
    0.0, 5.0 ];

  r8mat_print ( nv, 2, v, '  Polygon vertices:' );
%
%  Count the grid points.
%
  n = 7;
  ng = polygon_grid_count ( n, nv );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  N = %d\n', n );
  fprintf ( 1, '  Number of grid points will be NG = %d\n', ng );
%
%  Compute the grid points.
%
  xg = polygon_grid_points ( n, nv, v, ng );

  r8mat_print ( ng, 2, xg, '  The grid point array:' );
%
%  Display the points.
%
  filename = 'polygon_grid_points_test02.png';

  polygon_grid_display ( n, nv, v, ng, xg );

  print ( '-dpng', filename );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Plot written to the file "%s".\n', filename );
%
%  Write the points to a file.
%
  filename = 'polygon_grid_points_test02.xy';

  r8mat_write ( filename, ng, 2, xg );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Data written to the file "%s".\n', filename );

  return
end
