function xyz = triangle_xy_to_barycentric ( xy )

%*****************************************************************************80
%
%% triangle_xy_to_barycentric() rewrites an xy rule to xyz barycentric form.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real xy(:,2): a set of quadrature points in the reference triangle.
%
%  Output:
%
%    real xyz(:,3): the barycentric description of the quadrature points.
%
  [ m, n ] = size ( xy );

  if ( n ~= 2 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'triangle_xy_to_barycentric(): Fatal error!\n' );
    fprintf ( 1, '  xy() array second dimension is not 2.\n' );
    error ( 'triangle_xy_to_barycentric(): Fatal error!\n' );
  end

  xyz = zeros ( m, 3 );
  xyz(1:m,1:2) = xy(1:m,1:2);
  xyz(1:m,3) = 1.0 - xy(1:m,1) - xy(1:m,2);

  return
end
