www.gusucode.com > pde 案例源码 matlab代码程序 > pde/cardioid4.m

    function [x,y] = cardioid4(bs,s) 
% CARDIOID4 Geometry file defining the geometry of a cardioid. 

if nargin == 0  
  x = 4; % four segments in boundary
  return 
end

if nargin == 1
  dl = [0    pi/2   pi       3*pi/2
        pi/2   pi     3*pi/2   2*pi
        1      1      1        1
        0      0      0        0];
  x = dl(:,bs);   
  return 
end 

r = 2*(1+cos(s)); % s is not proportional to arc length
x = r.*cos(s);
y = r.*sin(s);
end