Doug's MAPLE recursive figure generator. First step: execute the following:Bigone:=proc(f,angle,length,x,y,n) local Self,k,xlist,ylist,j;
Self:=proc(f,angle,length,x,y,n)local i,x1,y1,newangle,pointt,Forward;
Forward:=proc(f,angle,length,x1,y1,n) local x2,y2;
if n=1 then
x2:=x1+length*cos(angle);
y2:=y1+length*sin(angle);
#print("FORWARD: n=1 processing. scale=",scale);
[x2,y2];
else
#print("FORWARD: Calling self. n=",n," scale=",scale);
Self(f,angle,length,x1,y1,n-1);
[xlist[k],ylist[k]]; #it must return SOMETHING
fi;
end;
x1:=x;y1:=y;
newangle:=angle;
for i from 1 to nops(f) do
#print("SELF: Beginning for loop. i=",i," n=",n);
if f[i]=0 then
#print("SELF: Moving forward n=",n);
pointt:= Forward(f,newangle,length,x1,y1,n);
k:=k+1; xlist[k]:=pointt[1]; ylist[k]:=pointt[2];
#print("SELF: In if statement, after forward. pointt:",pointt[1],pointt[2]);
else newangle:=angle+f[i];
#print("SELF: Changing angle n=",n);
pointt:=[x1,y1];
#print("SELF: In else statement, changing angle. pointt:",pointt[1],pointt[2]);
fi;
x1:=pointt[1];
y1:=pointt[2];
#print("SELF: End of for loop. i=",i," n=",n);
od;
end:
k:=1; xlist[1]:=x;ylist[1]:=y;
Self(f,angle,length,x,y,n);
seq([xlist[j],ylist[j]],j=1..k);
end:Okay - to draw your picture, you are going to type this:
M:=evalf(Bigone([your starting path in brackets],your starting angle,your starting length,your starting point,your desired recursion level)):
PLOT( CURVES( [M] ),SCALING(CONSTRAINED), AXESSTYLE(NONE) );The starting path goes like this: "0" for a step forward. A turn is indicated by an angle in radians. So to go forward, turn 45 degrees, and then go forward again, you enter [0,Pi/4,0]For example, to get the figure on my website (http://www.dougshaw.com/ap/recursive.html) to one level of recursion, we type:M:=evalf(Bigone([0,0,-Pi/2,0],Pi/2,1,0,0,1)):
PLOT( CURVES( [M] ),SCALING(CONSTRAINED), AXESSTYLE(NONE) );
And to get the figure I called "figure 2" (two levels of recursion):M:=evalf(Bigone([0,0,-Pi/2,0],Pi/2,1,0,0,2)):
PLOT( CURVES( [M] ),SCALING(CONSTRAINED), AXESSTYLE(NONE) );Got the idea? Now experiment and have fun! -doug