function [ i, j ] = xy_to_ij ( x, y )

%*****************************************************************************80
%
%% xy_to_ij() converts a point's (x,y) coordinates to (i,j) 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:
%
%    real X, Y: the Cartesian coordinates of the point.
%
%  Output:
%
%    real I, J, the parallelogram coordinates of a point.
%
  c = cos ( pi / 3.0 );
  s = sin ( pi / 3.0 );

  j = y / s;
  i = x - j * c;

  return
end

