function [xp,yp] = mapc2p(xc,yc)
%
% Map [-1,1] x [-1,1] to a starlike domain
% Mapping for Figure 8.4(a) as described in Section 8.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;

theta = atan(abs(yp) ./ max(abs(xp),1e-10));
r = 1 + .2*cos(6*theta);
xp = xp.*r;
yp = yp.*r;

