function [ f ] = spiralFib( N )
% Print the golden spiral with N Fibonacci numbers

   f=fibonacci(N);
   precision=0.1;

   up=true; % uppart of the circle
   left=true; % arc is on the left of the square
   side=1; % track the center of arc

   center=zeros(N,2); % [x,y] coordinate of the centers

   sig1=-1;
   sig2=1;

   % find the centers
   for i=3:N
      if mod(i,2)==0
         center(i,:)=center(i-1,:)+sig2*[0,f(i-2)];
         sig2=-1*sig2;
      else
         center(i,:)=center(i-1,:)+sig1*[f(i-2),0];
         sig1=-1*sig1;
      end
   end

   % Print the arc
   for i=1:N
      r=(f(i));
      if (left)
         x=(center(i,1)-r):precision:center(i,1);
      else
         x=center(i,1):precision:(center(i,1)+r);
      end
      if (up)
         y=center(i,2)+sqrt(r.^2-(x-center(i,1)).^2);
      else
         y=center(i,2)-sqrt(r.^2-(x-center(i,1)).^2);
      end
      plot(x,y,'*')
      hold on
      

      if side==1
         left=~left;
         side=2;
      else
         up=~up;
         side=1;
      end
   end
   hold off

end
