function [ alpha, beta, gamma ] = triangle_xy_to_xsi_2d ( ax, ay, bx, by, cx, cy, px, py )

%*****************************************************************************80
%
%% TRIANGLE_XY_TO_XSI_2D converts from XY to barycentric in 2D.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    05 December 2010
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real T(2,3), the triangle vertices.
%
%    Input, real P(2,1), the XY coordinates of a point.
%
%    Output, real XSI(3,1), the barycentric coordinates of the point.
%    XSI1 + XSI2 + XSI3 should equal 1.
%
  abc = triangle_area ( ax, ay, bx, by, cx, cy );
  pbc = triangle_area ( px, py, bx, by, cx, cy );
  apc = triangle_area ( ax, ay, px, py, cx, cy );
  abp = triangle_area ( ax, ay, bx, by, px, py );

  alpha = pbc / abc;
  beta  = apc / abc;
  gamma = abp / abc;

  return
end
