function triangle_cartesian_to_barycentric_test ( )

%*****************************************************************************80
%
%% triangle_cartesian_to_barycentric_test() tests triangle_cartesian_to_barycentric().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 July 2023
%
%  Author:
%
%    John Burkardt
%
  p_test = [ ...
     3.00,   0.00; ...
     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 ];

  p_num = size ( p_test, 1 );

  t = [ ...
     4.0, 2.0; ...
     1.0, 5.0; ...
    -2.0, 2.0 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Triangle vertices:\n' );
  disp ( t );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangle_cartesian_to_barycentric_test()\n' );
  fprintf ( 1, '  triangle_cartesian_to_barycentric() converts XY\n' );
  fprintf ( 1, '  Cartesian coordinates to barycentric XSI coordinates;\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '      Px          Py     =>   XSI(A)      XSI(B)      XSI(C) =>   Px          Py\n' );
  fprintf ( 1, '\n' );

  for i = 1 : p_num

    p = p_test(i,1:2);

    xsi = triangle_cartesian_to_barycentric ( t, p );

    p2 = xsi' * t;

    fprintf ( 1, '  %10f  %10f  %10f  %10f  %10f  %10f  %10f\n', p, xsi, p2 );

  end

  return
end
