function [x,y]=cardg(bs,s)
%CARDG Geometry File defining the geometry of a cardioid.

%       L. Langemyr 1-27-95.
%       Copyright 1994-2016 The MathWorks, Inc.

nbs=4;

if nargin==0
  x=nbs;
  return
end

dl=[    0       pi/2    pi      3*pi/2
        pi/2    pi      3*pi/2  2*pi;
        1       1       1       1
        0       0       0       0];

if nargin==1
  x=dl(:,bs);
  return
end


x=zeros(size(s));
y=zeros(size(s));
[m,n]=size(bs);
if m==1 && n==1
  bs=bs*ones(size(s)); % expand bs
elseif m~=size(s,1) || n~=size(s,2)
  error(message('pde:cardg:SizeBs'));
end

nth=400;
th=linspace(0,2*pi,nth);
r=2*(1+cos(th));
xt=r.*cos(th);
yt=r.*sin(th);
th=pdearcl(th,[xt;yt],s,0,2*pi);
r=2*(1+cos(th));
x(:)=r.*cos(th);
y(:)=r.*sin(th);


% LocalWords:  Langemyr
