function curve(t1,t2,n,d)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% utility for plotting parametric curves
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% M. Peszynska for MTH 254
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% examples: clf;curve(0,4*pi,100,6) %%% for the spiral
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=linspace(t1,t2,n);
hold on;
[x,y] = dcurve(t1);

for j=1:length(t)-1
    [xn,yn] = dcurve(t(j+1));
    plot([x,xn],[y,yn]);axis([-d d -d d]);axis equal;
    pause(0.1);
    x=xn;y=yn;    
end

function [x,y] = dcurve(t)
  r = 3 + 2*cos(t);  
x = r*cos(t);
   y = r*sin(t) ;
%    x = 2*t + exp(-t) +2;
%    y = t^2 - 1;

