function t2 = triangle_reflect ( t, r )

%*****************************************************************************80
%
%% triangle_reflect() reflects a polyiamond described by its triangle list.
%
%  Discussion:
%
%    The author confesses that he is currently unable to explain why this
%    formula works!
%
%    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:
%
%    16 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer T(TN,3), the IJK coordinates of the triangles of the polyiamond.  
%
%    integer R: the reflection option.
%    0: no reflection;
%    1: reflect about the I axis;
%    2: reflect about the J axis;
%    3: reflect about both I and J axes.
%
%  Output:
%
%    integer T2(TN,3), the IJK coordinates of the triangles of the 
%    reflected polyiamond.  
%
  t2 = t;

  if ( r == 1 )
    t2(:,1) = - t(:,1) - t(:,2) - t(:,3) + 2;
  elseif ( r == 2 )
    t2(:,1) = t(:,1) + t(:,2) + t(:,3) - 1;
    t2(:,2) = - t(:,2) + 1;
    t2(:,3) = 1 - t(:,3);
  elseif ( r == 3 )
    t2(:,1) = - t(:,1) + 1;
    t2(:,2) = - t(:,2) + 1;
    t2(:,3) = 1 - t(:,3);
  end

  return
end

