function [xp,yp] = mapc2p(xc,yc)
%
% map [-1,1] x [-1,1] to circle of radius r1
% mapping for Figure 3.2(d), radial projection followed by interpolation,
% as described in Section 3.3 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), 1e-10);
xp = r1 * d .* xc./r;
yp = r1 * d .* yc./r;

w = max(abs(xc),abs(yc)).^2;
xp = w.*xp + (1-w).*xc/sqrt(2);
yp = w.*yp + (1-w).*yc/sqrt(2);
