function bary = triangle_cartesian_to_barycentric ( t, p )

%*****************************************************************************80
%
%% triangle_cartesian_to_barycentric() converts Cartesian to barycentric coordinates.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    30 July 2023
%
%  Author:
%
%    John Burkardt
%
  bary = zeros ( 3, 1 );

  a = t(1,1:2);
  b = t(2,1:2);
  c = t(3,1:2);

  [ t, bary(1) ] = line_parameter_t ( b, c, p );
  [ t, bary(2) ] = line_parameter_t ( c, a, p );
  [ t, bary(3) ] = line_parameter_t ( a, b, p );

  bary = - bary;

  return
end
