Here is a Python turtle code for making a fractral tree, I had translation it to mathematica code(see Make a series of points curl):
Clear["`*"];
initial[position_, th_] :=
Module[{θ = th, pos = position},
left := θ += # &;
right := θ -= # &;
forward := (pos += #*{Cos[θ], Sin[θ]}; Sow[pos];) &;
backward := (pos -= #*{Cos[θ], Sin[θ]}; Sow[pos];) &;
];
tree[n_] :=
If[n > 5,
forward[n];
(*right[20 Degree];*)
left[-20 Degree];
tree[n - 15];
left[40 Degree];
tree[n - 15];
(*right[20 Degree];*)
left[-20 Degree];
backward[n]
];
initial[{0, 0}, Pi/2];(*initial conditions*)
point = Reap[tree[15 5]][[2, 1]];
Graphics[Line[point]]
I found AnglePath
would be better for this, but I don't know how to programmingly do this.
Graphics@Line@AnglePath[{{0,0},-(π/2)},{{45,180 °},{30,-20 °},
{15,-20 °},{15,180 °},{15,-140 °},{15,180 °},{30,-20 °},
{30,-140 °},{15,-20 °},{15,180 °},{15,-140 °},{15,180 °},{30,-20 °},{45,-20 °}}]
AnglePath
is the best function for this, since this involves a bunch of retracing. But it's probably better than that somewhat scary and non-local code. $\endgroup$ – Itai Seggev Aug 22 '17 at 1:38