function value = vertex_contains_ijk ( v, ijk )

%*****************************************************************************80
%
%% vertex_contains_ijk(): is a triangle in a polyiamond, given vertex list.
%
%  Discussion:
%
%    The vertex list of a polyiamond gives the IJ coordinates of the
%    polygonal vertices, in counterclockwise order.
%
%    This computation assumes that both the vertex list and the IJK
%    triangle description both use the same coordinate system, 
%    either the (i,j) coordinate system (which is expected) or 
%    the (x,y) coordinate system (which is generally NOT expected, but
%    should work).
%
%    The (i,j) coordinates refer to a parallelogram whose basic cell
%    is the unit parallelogram outlined by points (A,B,C,D)
%    with (i,j) coordinates
%      A = (0,0) --> B = (1,0) --> C = (1,1) --> D = (0,1).
%
%         D-----C
%        /     /
%       /     /
%      A-----B
%
%    Each cell is divided into k=0 and k=1 triangles:
%
%         *-----*
%        / \ 1 /
%       / 0 \ /
%      *-----*
%
%    Triangles are identified by a related (i,j,k) coordinate based 
%    on the (i,j) coordinates of its vertices:
%      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).
%
%    The (x,y) coordinates refer to the standard Cartesian coordinate
%    system, so that the unit parallelogram vertices have
%    (x,y) coordinates:
%      A = (0,0) --> B = (1,0) --> C = (1+c,s) --> D = (c,s),
%    where c = cos(60) = 0.5 and s = sin(60) = sqrt(3)/2.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer V(VN,2): the parallelogram point 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);

  if ( k == 0 )
    it(1) = i - 1;
    it(2) = i;
    it(3) = i - 1;
    jt(1) = j - 1;
    jt(2) = j - 1;
    jt(3) = j;
  else
    it(1) = i;
    it(2) = i - 1;
    it(3) = i;
    jt(1) = j;
    jt(2) = j;
    jt(3) = j - 1;
  end

  im = mean ( it );
  jm = mean ( jt );
  p = [ im, jm ];

  value = vertex_contains_point ( v, p );

  return
end

