java - Drawing a Fractal Tree by Processing -


i want draw fractal tree in processing, don't know how make it. , idea draw binary tree. tree must have more branches. , don't know how code it. please me, thanks.now have drawn 2d tree, boss ask me change 3d.and code,and don't know how make it.and i'm fresh man in processing programing.please me.

void tree(float treelength, float strokeweight, int currenttreestep) {     if (currenttreestep < maxtreesteps) {          if(currenttreestep >= 8 && currenttreestep <=10)             stroke(#558351); //set color light green         else{             if(currenttreestep >10 && currenttreestep <=20)                 stroke(#199b0e); //set hard green                     else{                 stroke(#311919);//set branch color             }         }         strokecap(project);         strokeweight(strokeweight);         line(0, 0, 0, -treelength);           translate(0, -treelength);          strokeweight *= 0.5;         treelength *= 0.75;          if (treelength > 1) {             pushmatrix();             rotate(radians(branchangle));             tree(treelength, strokeweight, currenttreestep + 1);             popmatrix();              pushmatrix();             rotate(-radians(branchangle));             tree(treelength, strokeweight, currenttreestep + 1);             popmatrix();         }       } } 

generally it's not intuitive 1 might move 2d(trigonometry mostly) 3d(linear algebra: vector , matrix multiplication).

have @ example 1 of courses did.

enter image description here

hopefully you'll see 3d matrix multiplication part in action well


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -