Dragon Curve

Author

Eric W. Weisstein
January 6, 2011

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Fractals/DragonCurve.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/DragonCurve.html.

©2010 Wolfram Research, Inc. except for portions noted otherwise

Plots

V5

Show[GraphicsArray[Partition[Table[DragonCurve[i],{i,9}],3]]]

V6

GraphicsGrid[Partition[Table[DragonCurve[i],{i,9}],3]]

Sequence

Dragon[1]:={1}
Dragon[n_]:=Join[Dragon[n-1],{1},ReplacePart[Dragon[n-1],1-Dragon[n-1][[2^(n-2)]],2^(n-2)]]

FromDigits/@Dragon/@Range[4]

Dragon[5]

FromDigits/@(IntegerDigits[FromDigits[#,2],8]&/@Dragon/@Range[5])

Recurrence Plot

l=Dragon[8];

ArrayPlot[Mod[Table[l[[x]]-l[[y]],{x,128},{y,128}],2],PixelConstrained->True]

Regular Paperfolding Sequence

DragonString[n_]:="F"<>StringJoin[Dragon[n]/.{0->"+F",1->"-F"}]

Show[GraphicsArray[
Partition[Block[{$DisplayFunction=Identity},
Show[TurtlePlot[#,Pi/2],AspectRatio->Automatic]&/@DragonString/@Range[10]],5]
],ImageSize->500]

Show[TurtlePlot[DragonString[12],Pi/2],AspectRatio->Automatic,ImageSize->500]

s=TurtlePlot[DragonString[8],Pi/2][[1,1]];
mm=Through[{Min,Max}[#]]&/@Transpose[s]
movie=Show[Graphics[#,AspectRatio->Automatic,PlotRange->mm]]&/@Line/@Reverse[NestList[Most,s,Length[s]-2]];

Length[movie]

Show[GraphicsArray[Partition[Take[movie,{1,256,16}],4]],ImageSize->500]

<<Utilities`GIF`;

Export[gifs<>"DragonCurve.gif",movie]//Timing