[math-fun] NxN generalization of Hilbert / Wunderlich Curves
AltFWord[let_, n_] := Riffle[Table[let, n], Table["F", n - 1]] MoveWord[2, "L"] = "+RF-LFL-FR+"; MoveWord[2, "R"] = "-LF+RFR+FL-"; MoveWord[n_, "L"] := If[OddQ[n], "", "+"] <> StringTake[ MoveWord[n - 1, "R"] <> "F-" <> AltFWord["L", n] <> "-" <> AltFWord["R", n][[2 ;; -1]] <> "+", {If[OddQ[n], 2, 1], -1}]; MoveWord[n_, "R"] := If[OddQ[n], "", "-"] <> StringTake[ MoveWord[n - 1, "L"] <> "F+" <> AltFWord["R", n] <> "+" <> AltFWord["L", n][[2 ;; -1]] <> "-", {If[OddQ[n], 2, 1], -1}]; HilbertGen[n_] := {"L" -> MoveWord[n, "L"], "R" -> MoveWord[n, "R"]} ToVec[str_] := FoldList[Switch[#2, "+", #1*{1, I}, "-", #1*{1, -I}, "F", {Total[#1], #1[[2]]}, _, #1] &, {0, 1}, Characters[str]] Grid[Transpose@{Function[{n}, Labeled[ Map[Graphics[{Line[ReIm[ToVec[#][[All, 1]]]]}, ImageSize -> 500] &, NestList[StringReplace[#, HilbertGen[n]] &, "L", 2]][[-1]], n] ] /@ Range[2, 10]}, Frame -> All] Out[]:= https://0x0.st/zvPI.png
Nice pic(s), but I cannot decode the method! Best regards, jj * Brad Klee <bradklee@gmail.com> [Sep 28. 2019 17:51]:
AltFWord[let_, n_] := Riffle[Table[let, n], Table["F", n - 1]]
MoveWord[2, "L"] = "+RF-LFL-FR+"; MoveWord[2, "R"] = "-LF+RFR+FL-";
MoveWord[n_, "L"] := If[OddQ[n], "", "+"] <> StringTake[ MoveWord[n - 1, "R"] <> "F-" <> AltFWord["L", n] <> "-" <> AltFWord["R", n][[2 ;; -1]] <> "+", {If[OddQ[n], 2, 1], -1}];
MoveWord[n_, "R"] := If[OddQ[n], "", "-"] <> StringTake[ MoveWord[n - 1, "L"] <> "F+" <> AltFWord["R", n] <> "+" <> AltFWord["L", n][[2 ;; -1]] <> "-", {If[OddQ[n], 2, 1], -1}];
HilbertGen[n_] := {"L" -> MoveWord[n, "L"], "R" -> MoveWord[n, "R"]}
ToVec[str_] := FoldList[Switch[#2, "+", #1*{1, I}, "-", #1*{1, -I}, "F", {Total[#1], #1[[2]]}, _, #1] &, {0, 1}, Characters[str]]
Grid[Transpose@{Function[{n}, Labeled[ Map[Graphics[{Line[ReIm[ToVec[#][[All, 1]]]]}, ImageSize -> 500] &, NestList[StringReplace[#, HilbertGen[n]] &, "L", 2]][[-1]], n] ] /@ Range[2, 10]}, Frame -> All]
Out[]:= https://0x0.st/zvPI.png
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
After Hilbert's N=2 and Wunderlich's N=3, every rule is the rule for N-2, with an extra two right angle turns concatenated on the end. I found the general construction procedure inductively, by studying the first few cases: https://0x0.st/zvIm.png ( blue / green triangles correspond to L / R symbols, arrows to F ) These curves have been drawn before, but I didn't look at the details. During a background search, Google revealed another oddity, which I had never seen or thought of: http://bl.ocks.org/nitaku/dcce9b645783d5239a04 Don't know if anyone has tried to answer the question of counting all possible Z^2 space-filling curves with NxN replacement grid, but it should be possible at least by brute force enumeration. --Brad On Mon, Sep 30, 2019 at 9:37 AM Joerg Arndt <arndt@jjj.de> wrote:
Nice pic(s), but I cannot decode the method!
Best regards, jj
participants (2)
-
Brad Klee -
Joerg Arndt