Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Pythagoras-tree/Mathematica/pythagoras-tree.math
Normal file
17
Task/Pythagoras-tree/Mathematica/pythagoras-tree.math
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
n = 7;
|
||||
colors = Blend[{Orange, Yellow, Green}, #] & /@ Subdivide[n - 1];
|
||||
ClearAll[NextConfigs, NewConfig]
|
||||
NewConfig[b1_List, b2_List] := Module[{diff, perp},
|
||||
diff = b2 - b1;
|
||||
perp = Cross[b2 - b1];
|
||||
<|"quad" -> Polygon[{b1, b2, b2 + perp, b1 + perp}], "triang" -> Polygon[{b1 + 1.5 perp + diff/2, b1 + perp, b2 + perp}]|>
|
||||
]
|
||||
NextConfigs[config_Association] := Module[{tr},
|
||||
tr = config["triangs"][[All, 1]];
|
||||
tr = Join[NewConfig @@@ tr[[All, {2, 1}]], NewConfig @@@ tr[[All, {1, 3}]]];
|
||||
<|"quads" -> tr[[All, "quad"]], "triangs" -> tr[[All, "triang"]]|>
|
||||
]
|
||||
nc = NewConfig[{-0.5, 0.0}, {0.5, 0.0}];
|
||||
config = <|"quads" -> {nc["quad"]}, "triangs" -> {nc["triang"]}|>;
|
||||
config = NestList[NextConfigs, config, n - 1];
|
||||
Graphics[MapThread[{EdgeForm[Black], FaceForm[#2], #1["quads"], #1["triangs"]} &, {config, colors}]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue