function value = vertex_contains_ijk ( v, ijk )

%*****************************************************************************80
%
%% vertex_contains_ijk(): is a triangle in a polyabolo, given vertex list.
%
%  Discussion:
%
%    The vertex list gives the IJ coordinates of the
%    polygonal vertices, in counterclockwise order.
%
%    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:
%
%    08 December 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer V(VN,2): the indices of the vertices, in counterclockwise order.
%
%    integer IJK(3): the parallelogram triangle index.
%
%  Output:
%
%    logical VALUE: is true if the triangle is in the region.
%
  i = ijk(1);
  j = ijk(2);
  k = ijk(3);
%
%  Determine coordinates of the centroid of the triangle.
%
  il = i - 0.75;
  im = i - 0.50;
  ih = i - 0.25;

  jl = j - 0.75;
  jm = j - 0.50;
  jh = j - 0.25;

  if ( k == 0 )
    ic = im;
    jc = jl;
  elseif ( k == 1 )
    ic = ih;
    jc = jm;
  elseif ( k == 2 )
    ic = im;
    jc = jh;
  elseif ( k == 3 )
    ic = il;
    jc = jm;
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, 'vertex_contains_ijk(): Fatal error!\n' );
    fprintf ( 1, '  Illegal value of k = %d\n', k );
    error ( 'vertex_contains_ijk(): Fatal error!' );
  end

  p = [ ic, jc ];

  value = vertex_contains_point ( v, p );

  return
end

