function value = triangle_ijk_in_region ( i, j, k, iv, jv )

%*****************************************************************************80
%
%% triangle_ijk_in_region determines if a triangle is in a region.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 September 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer I, J, K: the parallelogram triangle index.
%
%    integer IV(NV), JV(NV): the parallelogram point indices of the
%    vertices, in counterclockwise order.
%
%  Output:
%
%    logical VALUE: is true if the triangle is in the region.
%
  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 );
  value = point_in_polygon ( im, jm, iv, jv );

  return

  it(1:3) = 0.95 * it(1:3) + 0.05 * mean ( it );
  jt(1:3) = 0.95 * jt(1:3) + 0.05 * mean ( jt );

  value = point_in_polygon ( it(1), jt(1), iv, jv ) && ...
          point_in_polygon ( it(2), jt(2), iv, jv ) && ...
          point_in_polygon ( it(3), jt(3), iv, jv );

  return
end

