% Script spiral
% Draws a logarithmic spiral

% Parameters of the spiral:
turnAngle = 65;
numEdges = 400;
spiralColor1 = 'red';
spiralColor2 = 'blue';

% Set up the plot window...
close all
set(0,'defaultfigureposition',[128 64 800 600])
figure
axis equal off

% Color is specified by a 3-element vector, each component between 0 and 1.
% The numbers specify the red, green, and blue content respectively.

set(gcf,'color','black')
hold on

% Spiral starts at (0,0)
x_c= 0;
y_c= 0;

for k= 1:numEdges

% Direction of the k-th edge
theta= (k*turnAngle)*(pi/180);

% k-th edge starts at (x_c,y_c) and ends at (x_next,y_next)
x_next= x_c + k*cos(theta);
y_next= y_c + k*sin(theta);

% plot the k-th edge
if rem(k,2)==1
plot([x_c x_next],[y_c y_next],'color',spiralColor1)
else
plot([x_c x_next],[y_c y_next],'color',spiralColor2)
end

% The "start" of the next leg is the "end" of the current leg
x_c= x_next;
y_c= y_next;

end

hold off
title(sprintf('Edges = %d Turn Angle (degrees) = %3d',numEdges,turnAngle),'color','white')
shg