%cornu spiral(euler spiral)
%
t = -2.5:0.005:2.5;
len= length(t);
x = zeros(1,len);
y = zeros(1,len);
%variants of cornu spiral,last one t.^2 is basic
liststr = {'(-0.6*t+0.2*t.^5-0.1*t.^3))';
'(t.^7-t.^3-t-2))';
'(t.^5-3*t.^3-t))';
'(t.^7-4*t))';
'(4*t.^5+t.^3-4*t))';
'(t.^7-t.^5-2*t-12))';
'(t.^7-t.^5-2*t.^3-1))';
'(t.^3+t-2))';
'(t.^3-2.335*t))';
'(t.^3-4.27*t))';
'(9*t.^5-18*t.^3+5*t))';
'(t.^2))';
'(t.^5+0.6*t-4*t.^3))';
'(-t.^5-0.6*t+3*t.^3))';
'(-t.^7+0.1*t-3*t))';
'(t.^3-2*t.^5+0.3*t.^9-t))';
'(t.^3-0.2*t.^5+1.5*t))';
'(t.^3-0.1*t.^7+1.5*t))'};
[option_num,v] = listdlg('PromptString','Select',...
'SelectionMode','single',...
'ListString',liststr);
if v==1
a = liststr{option_num};
h_wait = waitbar(0,'Please wait...');
s1 = inline(['sin(0.5*pi*' a]);
s2 = inline(['cos(0.5*pi*' a]);
for n = 2:len
x(n) = x(n-1)+quad(s1,t(n-1),t(n)); %evaluation of fresnel integral
y(n) = y(n-1)+quad(s2,t(n-1),t(n)); %evaluation of fresnel integral
waitbar(n/len,h_wait);
end
close(h_wait)
%simple plot
plot(y,x,'LineWidth',2,'Color',[0 0 0.7]);
legend([liststr{option_num}])
axis off,box off
daspect([1 1 1])
%tube plot
figure
z = ones(size(t));
verts = {[5*y' 5*x' z']};
daspect([1 1 1])
h1 = streamtube(verts,0.2);
set(h1,'Facecolor',[rand(1,3)],'edgecolor','none');
camlight headlight;
lighting gouraud
axis tight
view(-59,21)
zoom(1.7)
%ribbon plot
figure
twistangle = {t/20000};
width=0.3;
verts = {[5*y' 5*x' z']};
daspect([1 1 1])
h2 = streamribbon(verts,twistangle,width);
set(h2,'Facecolor',[rand(1,3)],'edgecolor','none');
camlight headlight;
camlight(10,20);
camlight(100,40);
camlight(51,50);
lighting phong
material metal
axis tight
view(-59,21)
end