How to make this Dragon Curve?
I think OP may want animation with transition effects. Compare these two effects:
Then translation
Clear["`*"]
cf = Compile[{{M, _Real, 2}, t},
With[{A = M[[1]], B = M[[2]]},
With[{P = (A + B + t Cross[B - A])/2}, {{A, P}, {B, P}}]], RuntimeAttributes -> Listable
];
f[n_] := Flatten[Nest[cf[#, 1] &, {{{0, 0}, {1, 0}}}, Floor@n], Floor@n];
g[n_] := Flatten[cf[f[n], FractionalPart[n]], 1];
Manipulate[Graphics[{Line[f[n]]}, PlotRange -> {{-0.4, 1.2}, {-0.4, 0.7}}], {n, 0, 12}]
Manipulate[Graphics[{Line[g[n]]}, PlotRange -> {{-0.4, 1.2}, {-0.4, 0.7}}], {n, 0, 12}]
Manipulate[
With[{i = Floor[n], TF = TranslationTransform},
Graphics[{
Table[Line[TF[{2 j, 0}]@f[j]], {j, 0, n}],
Line@If[n - i < 0.5, TF[{4 n - 2 i, 0}]@f[n], TF[{2 i + 2, 0}]@g[2 n - i - 1]]
}, ImageSize -> 670, PlotRange -> {{-0.2, 13.2}, {-0.5, 0.8}}]],
{n, 0, 6}]
A simple way to make Dragon Curve is using AnglePath
. Define a function that generates points for the Dragon curve:
dragonPTS[k_]:=AnglePath[{Pi/2,-Pi/2}[[1+Nest[Join[#,{0},Reverse[1-#]]&,{0},k]]]]
k
is an integer number of iterations. Try it out:
Graphics[Line[dragonPTS[10]]]
Now generate a list of the transitions:
Table[Graphics[Line[dragonPTS[k]]], {k, 1, 10, 1}]
or animate:
Manipulate[Table[Graphics[Line[dragonPTS[k]]], {k, 1, n, 1}], {n, 1, 10}]
To make it a bit cleaner - as in the top animation image - you can try:
Manipulate[
Row[Table[Graphics[Line[dragonPTS[k]],ImageSize->100{1,1}],{k,1,n,1}]],
{n,1,10,1},Paneled->False,AppearanceElements->None]
Also see numerous interactive apps at Demonstrations Project:
https://demonstrations.wolfram.com/search.html?query=Dragon