function triangle_sample_test ( )

%*****************************************************************************80
%
%% triangle_sample_test tests triangle_sample.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    20 February 2019
%
%  Author:
%
%    John Burkardt
%
  n = 10000;

  v = [ ...
    0.75, 0.90;...
    0.00, 0.20; ...
    0.95, 0.65 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangle_sample_test\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Test triangle_sample, which uniformly samples a triangle.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of points N = %d\n', n );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Vertices:\n' );
  fprintf ( 1, '  V1 = %12f  %12f\n', v(1,1:2) );
  fprintf ( 1, '  V2 = %12f  %12f\n', v(2,1:2) );
  fprintf ( 1, '  V3 = %12f  %12f\n', v(3,1:2) );

  x = triangle_sample ( v, n );

  figure ( );
  clf
  hold on
  plot ( [ v(1,1), v(2,1), v(3,1), v(1,1) ], [ v(1,2), v(2,2), v(3,2), v(1,2) ], 'k-', 'linewidth', 3 );
  plot ( x(:,1), x(:,2), 'b.', 'markersize', 5 );
  grid ( 'on' );
  axis ( 'equal' );
  xlabel ( '<-- X -->' );
  ylabel ( '<-- Y -->' );
  title ( 'Uniform points by triangle\_sample()' );
  filename = 'triangle_sample_test.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

