%
%  w10neph.m -- (djm:  11 mar 2004)
%    - nephroid
%

%  coordinates
dy = 0.2/4;  y  = -1+dy/2:dy:1-dy/2;  N = size(y,2);
th = asin(y);

%  draw lines
figure(1);  clf;  hold on

for j = 1:N
    x = -cos(th(j)):0.1:2;
    plot(x,y(j)*ones(size(x)),'g--')
    if (cos(2*th(j))>0)
        y1 = -tan(2*th(j))*(x+cos(th(j)))+sin(th(j));
    else
        x = -cos(th(j)):-0.1:-2;
        y1 = -tan(2*th(j))*(x+cos(th(j)))+sin(th(j));
    end
    plot(x,y1,'b')
end

for j = 1:N
    xc = (cos(th(j))^2-1.5)*cos(th(j));
    xc = (cos(3*th(j))-3*cos(th(j)))/4;
    xc = cos(th(j))^3-3*cos(th(j))/2;
    yc = -tan(2*th(j)) * (xc+cos(th(j))) + sin(th(j));
    yc = (sin(3*th(j))-3*sin(th(j)))/4;
    yc = sin(th(j))^3;
    plot(xc,yc,'k.')
end
    
%  plot circle
theta = 0.5*pi:pi/50:1.5*pi;
plot(cos(theta),sin(theta),'k')
axis equal;
axis([-1.1 1.8 -1.2 1.2]);

title('\bf nephroid')
xlabel('\bf x-axis')
ylabel('\bf y-axis')

