function [xp,yp] = mapc2p(xc,yc)
%
% Map [-1,1] x [-1,1] to circle of radius r1
% Radial projection mapping as described in Section 3.1 of
%    Logically Rectangular Grids and Finite Volume Methods for PDEs
%         in Circular and Spherical Domains,
%    by Donna A. Calhoun, Christiane Helzel, and Randall J. LeVeque,
%    http://www.amath.washington.edu/~rjl/pubs/circles

r1 = 1;
d = max(abs(xc),abs(yc));
r = max(sqrt(xc.^2 + yc.^2); 
r = max(r, 1e-10);           % to avoid divide by zero at origin
xp = r1 * d .* xc./r;
yp = r1 * d .* yc./r;

