# HybridPythagorasTree

Loading 3D model
of HybridPythagorasTree

### Comments

comments powered by Disqus

### Source code

 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 lsystem HybridPythagorasTree(angle = 40, i = 7, minSize = 7, thn = false) extends Branches {  set symbols axiom = /(45) F(64, 0); set iterations = i; set randomSeed = 3; let gradient = toColorGradient(#7B3C12, i, #00FF00);  set cameraPosition = {181, 107, 221}; set cameraUpVector = {1, -0.03, -0.11}; set cameraTarget = {129, -17, 10};  let angleComp = 90 - angle; // angle complement let sinAngle = sin(deg2rad(angle)); let sinAngleComp = sin(deg2rad(angleComp));  interpret E(x, i) as lsystem MengerSponge(if(thn, x/2, x), gradient[i]); interpret m(x) as MoveForward(if(thn, x/2, x)); interpret + as Yaw(angle); interpret - as Yaw(-angleComp); interpret / as Roll;  rewrite F(x, i) with left = x * sinAngle, right = x * sinAngleComp where x > minSize to E(x, i) [ + m(left / 2) F(right, i + 1) ] - m(right / 2) F(left, i + 1);} abstract lsystem MengerSponge(size = 1, color = #FFFFFF) extends Branches {  let iters = if(size > 60, 2, if(size > 10, 1, 0));  let cubeSize = size * (1/3)^iters; let halfSize = cubeSize / 2;  let renderBlooms = iters == 0; let iters = iters + if(renderBlooms, 1, 0); // to render blossoms  set iterations = iters; set symbols axiom = F;  interpret F as DrawForward(cubeSize, cubeSize, color); interpret f as MoveForward(halfSize); interpret B as lsystem Bloom(cubeSize); interpret + as Yaw(90); interpret - as Yaw(-90); interpret ^ as Pitch(90); interpret & as Pitch(-90);  rewrite F where renderBlooms to F [ ^ f B ]; rewrite F to - f f + & f f ^ F F F +f+f- F F +f+f- F F +f+f- F -f+f+f^f F F &f&f^ F F &f&f^ F ^ ^ f f f & + f F F &f&f^ F ^ ^ f f f & + f F F &f&f^ F ^ ^ f f f & + f F f & f f ^ + + f f - f f f f f; rewrite f to f f f;} abstract lsystem Bloom(size = 1) extends Polygons { let color = #d649ff; let leafCount = floor(random(4, 7)); let angle = 150 / leafCount;  set symbols axiom = F [ G(size/6) K ] leaf; set iterations = leafCount;  interpret F as DrawForward(size * 0.5, size * 0.2, color); interpret G as MoveForward(size * 0.5); interpret K as DrawSphere(size / 8, #ffff00);  interpret + as Yaw(angle); interpret - as Yaw(-angle); interpret | as Yaw(180); interpret / as Roll;  interpret ^ as Pitch(-15);  rewrite leaf to /(360 / leafCount) [ ^(20 + 8*size) <(color) . + ^ G . - ^ G . - ^ G . + | + G . - ^ G . > ] leaf;} process all with ThreeJsRenderer;

### Thumbnail extension

 1234 process HybridPythagorasTree(40, 6, 5, true) with ThreeJsRenderer set cameraPosition = {68, 59, 105} set cameraUpVector = {1.01, 0.02, 0.02} set cameraTarget = {59, -4, 6};