
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.




Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or trigonometric functions).




Related tasks
 Fractal tree


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}]]