% cardioiden
clf
shg
t=linspace(0,2*pi,200);
x=2*cos(t)-cos(2*t); y=2*sin(t)-sin(2*t);
for i=1:length(t)
    plot(cos(t),sin(t),'b'), hold on
    plot(2*cos(t(i))+cos(t),2*sin(t(i))+sin(t),'g')
    plot(x(1:i),y(1:i),'r',x(i),y(i),'mo'), hold off
    axis equal, axis([-3.2 3.2 -3.2 3.2]), title('Cardioid')
    pause(0.1)
end