function triangle_contains_point_test ( )

%*****************************************************************************80
%
%% TRIANGLE_CONTAINS_POINT_TEST tests TRIANGLE_CONTAINS_POINT.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    07 June 2006
%
%  Author:
%
%    John Burkardt
%
  test_num = 7;

  p_test = [ ...
     0.25,   0.25; ...
     0.75,   0.25; ...
     1.00,   1.00; ...
    11.00,   0.50; ...
     0.00,   1.00; ...
     0.50, -10.00; ...
     0.60,   0.60 ]';
  t = [ ...
    0.0, 1.0; ...
    0.0, 0.0; ...
    1.0, 0.0 ]';

  fprintf ( 1, '\n' );
  fprintf ( 1, 'TRIANGLE_CONTAINS_POINT_TEST\n' );
  fprintf ( 1, '  TRIANGLE_CONTAINS_POINT reports if a point \n' );
  fprintf ( 1, '  is inside a triangle\n' );

  r8mat_transpose_print ( 2, 3, t, '  Triangle vertices:' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '     X       Y     Inside\n' );
  fprintf ( 1, '\n' );

  for j = 1 : test_num

    p(1:2) = p_test(1:2,j);

    inside = triangle_contains_point ( t, p );

    fprintf ( 1, '  %10f  %10f  %1d\n', p(1:2), inside );

  end
%
%  Make a copy of the triangle with vertices in reverse order.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Repeat the test, but reverse the triangle vertex ordering.\n' );
 
  for j = 1 : 3
    t2(1:2,j) = t(1:2,4-j);
  end

  r8mat_transpose_print ( 2, 3, t2, '  Triangle vertices (reversed):' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '     X       Y     Inside\n' );
  fprintf ( 1, '\n' );

  for j = 1 : test_num

    p(1:2) = p_test(1:2,j);

    inside = triangle_contains_point ( t2, p );

    fprintf ( 1, '  %10f  %10f  %1d\n', p(1:2), inside );

  end
 
  return
end
