Pythagoras tree rounded
by NightElfik
Short link: http://malsys.cz/g/uxVd2UMo
Comments
comments powered by DisqusSource code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // angle should be between 0 and 90 (exclusive) lsystem PythagorasTree(angle = 40) extends Branches { set symbols axiom = F(128); set iterations = 11; set initialAngle = 90; let angleComp = 90 - angle; // angle complement let sinAngle = sin(deg2rad(angle)); let sinAngleComp = sin(deg2rad(angleComp)); interpret E(x) as DrawForward(x, x); interpret m as MoveForward; interpret + as TurnLeft(angle); interpret - as TurnLeft(-angleComp); rewrite F(x) with left = x * sinAngle, right = x * sinAngleComp to E(x) [ + m(left / 2) F(right) ] - m(right / 2) F(left); } process all with SvgRenderer; |