function q = ij_to_xy ( p )

%*****************************************************************************80
%
%% ij_to_xy() converts a point's (i,j) coordinates to (x,y) form.
%
%  Discussion:
%
%    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
%
%    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:
%
%    11 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer P(2) the parallelogram coordinates of a point.
%
%  Output:
%
%    real Q(2): the Cartesian coordinates of the point.
%
  c = cos ( pi / 3.0 );
  s = sin ( pi / 3.0 );

  q = zeros ( size ( p ) );

  q(1) = p(1) + p(2) * c;
  q(2) =        p(2) * s;

  return
end

