function t = vertex_to_triangle ( v )

%*****************************************************************************80
%
%% vertex_to_triangle() converts a polyabolo from vertex list to triangle list.
%
%  Discussion:
%
%    The vertex list of a polyabolo gives the IJ coordinates of the
%    polygonal vertices, in counterclockwise order.
%
%    The triangle list gives the IJK coordinates of triangles inside the polyabolo.
%    The (i,j) coordinates refer to a grid whose basic cell
%    is the unit square outlined by points (A,B,C,D):
%      A = (0,0) --> B = (1,0) --> C = (1,1) --> D = (0,1).
%
%      D-----C
%      |     |
%      |     |
%      |  E  |
%      |     |
%      |     |
%      A-----B
%
%    Each cell is divided into triangles with index k = 0, 1, 2, 3:
%
%      D-----C
%      |\ 2 /|
%      | \ / |
%      |3 E 1|
%      | / \ |
%      |/ 0 \|
%      A-----B
%
%    Triangles are identified by a related (i,j,k) coordinate based 
%    on the (i,j) coordinates of its vertices:
%      k = 0: A, B, E.
%      k = 1: B, C, E.
%      k = 2: C, D, E
%      k = 3: D, A, E
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 December 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer V(VN,2): the (I,J) parallelogram vertices, in counterclockwise order.
%
%  Output:
%
%    integer T(TN,3), the IJK coordinates of triangles in the polyabolo.  
%

%
%  Determine the extent of the grid.
%
  imin = min ( v(:,1) );
  imax = max ( v(:,1) );
  jmin = min ( v(:,2) );
  jmax = max ( v(:,2) );
%
%  Consider each triangle in the 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 : 3
        ijk = [ i, j, k ];
        if ( vertex_contains_ijk ( v, ijk ) )
          tn = tn + 1;
          t = [ t; i, j, k ];
        end
      end
    end
  end

  return
end

