home *** CD-ROM | disk | FTP | other *** search
- /*
- * Tree model from the book 'The algorithmic beauty of plants'
- * by P. Prudinkiewicz and A. Lindenmayer, p. 60.
- *
- * Leafs are added to the model described in the book. This is
- * realized using macros. The leaf model is out of the book as well.
- * (p. 124).
- *
- * 30.10.92 Christoph Streit (streit@iam.unibe.ch)
- */
-
- lsystem TreeWithLeafs;
-
- /*
- * Generate trunk and branches.
- */
- table Tree {
- const d1 = 180.0; // divergence angle 1
- d2 = 252; // divergence angle 2
- a = 36; // branching angle
- lr = 1.070; // elongation rate
- vr = 1.732; // width increase rate
- vr2 = 1; // width increase rate 2
-
- A(n):n < 4 -> we(0.001) wi(vr) F(50)
- [pt(a) F(50) A(n+1)] ro(-d1)
- [pt(a) F(50) A(n+1)] ro(-d2)
- [pt(a) F(50) A(n+1)];
-
- A(n):n >= 4 -> we(1) wi(vr2) F(50)
- [pt(a) F(50) leafs A(n+1)] ro(-d1)
- [pt(a) F(50) leafs A(n+1)] ro(-d2)
- [pt(a) F(50) leafs A(n+1)];
- F(l) -> F(l*lr);
- wi(w) -> wi(w*vr);
- };
-
- /*
- * Attach the leafs to the branches.
- */
- table Leafs {
- leafs -> [
- [pt(45) F(15,0.4) [pt(45) xm("leaf", 0.1)]
- [pt(-45) xm("leaf", 0.1)]
- xm("leaf", 0.1)
- ]
- [pt(-45) F(15,0.4) [pt(45) xm("leaf", 0.1)]
- [pt(-45) xm("leaf", 0.1)]
- xm("leaf", 0.1)
- ]
- ];
- };
-
- /*
- * Macro definition for the leaf, which will be attached due to
- * the table Leafs.
- */
- table LeafDef {
- const LA=5; // initial length - main segment
- RA=1.1; // growth rate - main segment
- LB=2.2; // initial length - lateral segment
- RB=1.21; // growth rate - lateral segment
- SD=1;
- DW=1.01;
- PD=0.9; // growth potential decrement
-
- leafDef -> sm("leaf")
- { co("green") sv C(0) }
- em;
-
- C(t) -> f(LA, 1, RA)
- [
- tu(-60) B(t) sv][C(t+1)][tu(60) B(t) sv
- ];
- B(t) : t>0 -> f(LB, SD, RB) B(t-PD);
- f(s,w,r) -> f(s*r, w*DW, r);
- };
-
- attributes {
- axiom t(1,0,0, 0) // add some tropism
- leafDef // generate the leaf macro
- co("SaddleBrown") wi(1) F(200) ro(-45) A(1);
- derivation Tree(6), Leafs(1), LeafDef(20);
-
- coneres 5;
- };
-