function [xp,yp] = mapc2p(xc,yc)
%
% Specifies the mapping from computational to physical coordinates.
% Maps the square [-1,1] x [-1,1] to the unit circle.
%
%  Wave Propagation Software, Computational Science, and Reproducible Research
%  by R. J. LeVeque, http://www.amath.washington.edu/~rjl/pubs/icm06
%

xc1 = max(abs(xc),1e-10);
yc1 = max(abs(yc),1e-10);
alpha = min(1./xc1, 1./yc1);
beta = alpha.*sqrt(xc1.^2 + yc1.^2);
xp = xc./beta;
yp = yc./beta;

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