function t = vertex_to_triangle ( v )

%*****************************************************************************80
%
%% vertex_to_triangle() converts a polyiamond from vertex list to triangle list.
%
%  Discussion:
%
%    The vertex list of a polyiamond gives the IJ coordinates of the
%    polygonal vertices, in counterclockwise order.
%
%    The triangle list is a list of the IJK parallelogram triangles
%    that constitute the polyiamond.
%    If k = 0, the "ijk" triangle has vertices
%      (i-1,j-1), (i,j-1), (i-1,j).
%    If k = 1, the "ijk" triangle has vertices
%      (i,j), (i-1,j), (i,j-1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer V(VN,2): the (I,J) parallelogram vertices, in counterclockwise order.
%
%  Output:
%
%    integer T(TN,3), the IJK parallelogram triangle coordinates of the 
%    triangles making up the polyiamond.  
%

%
%  Determine the extent of the parallelogram grid.
%
  imin = min ( v(:,1) );
  imax = max ( v(:,1) );
  jmin = min ( v(:,2) );
  jmax = max ( v(:,2) );
%
%  Consider each triangle in the parallelogram grid.
%  If it is in the region, add it to the list.
%
  tn = 0;
  t = zeros ( tn, 3 );

  for j = jmin + 1 : jmax + 1
    for i = imin + 1 : imax + 1
      for k = 0 : 1
        ijk = [ i, j, k ];
        if ( vertex_contains_ijk ( v, ijk ) )
          tn = tn + 1;
          t = [ t; i, j, k ];
        end
      end
    end
  end

  return
end

