Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random as rd
- leafduration = 4 # life time of a leaf
- leafold = 2 # age at which a leaf is considered as old
- maxorder = 1 # maximum number of branching order
- radinc = 0.15 # increment of radius through time
- rand = 0.001
- maxduration = lambda order : int(5./(order+1))+5 # life time of an apex
- branch_angle = lambda order : 20 # branching angle
- branch_angle2 = lambda order : 30 # branching angle
- # number of axe at a ramification
- nb_axes = lambda order : rd.randint(2,4) if order > 2 else rd.randint(4-int((order+1)/2),5-int((order+1)/2))
- up_angle3 = lambda t,order : -35
- up_angle = lambda t,order : -30
- up_angle2 = lambda t,order : -25
- up_angle1 = lambda t,order : -20 # up angle for lateral branches
- up_angle11 = lambda t,order : -15
- up_angle111 = lambda t,order : -10
- up_angle1111 = lambda t,order : -7
- up_angle0 = lambda t,order : -4
- # number total of iterations of the system
- nbiter = sum([maxduration(o) for o in xrange(maxorder+1)])
- module A # represent trunk apical meristem
- module B # represent apical meristem of lateral branches
- module L # whorl of leaf
- module I # Internode
- Axiom: _(1.5)@GcI(0,1)A(0,0)
- derivation length: nbiter
- production:
- A(t,o) :
- if t < maxduration(o):
- # simply produces a metamer and ages the apex
- produce I(2,0.3)A(t+1,o)
- else:
- # produce a whorl of sympodial branches
- nbaxe = nb_axes(o)
- q = 0
- if q == 0:
- for i in range(14):
- nproduce [/(130*i/5)B3(0,8)]
- nproduce [/(90*i/5)B(0,10)]
- nproduce [/(130*i/5)B2(0,8)]
- q = q+1
- if q == 1:
- for i in range(9):
- nproduce [/(360*i/5)B1(0,6)]
- nproduce [/(120*i/5)B11(0,4)]
- nproduce [/(240*i/5)B111(0,2)]
- q = q+1
- if q == 2:
- for i in range(12):
- nproduce [/(135*i/5)B1111(0,1)]
- if q == 3:
- for i in range(3):
- nproduce [/(60*i/5)B0(0,1)]
- produce @O(2);(5)
- B(t,o) :
- produce ^(up_angle(t,o))I1(1,0)L(1,11)L(0,t)L(0,t)L(0,t)I1(1,0)L(0,t)I1(1,0)L(0,t)B(t+1,o)
- B0(t,o) :
- produce ^(up_angle0(t,o))I1(1,0)L(1,11)L(0,t)L(0,t)L(0,t)I1(1,0)L(0,t)I1(1,0)L(0,t)B0(t+1,o)
- B2(t,o) :
- produce ^(up_angle2(t,o))I1(1,0)L(1,11)L(0,t)L(0,t)L(0,t)I1(1,0)L(0,t)I1(1,0)L(0,t)B2(t+1,o)
- B1(t,o) :
- produce ^(up_angle1(t,o))I1(1,0)L(1,11)L(0,t)L(0,t)L(0,t)I1(1,0)L(0,t)I1(1,0)L(1,11)B1(t+1,o)
- B11(t,o) :
- produce ^(up_angle11(t,o))I1(1,0)L(1,11)L(0,t)L(0,t)L(0,t)I1(1,0)L(0,t)I1(1,0)L(1,11)B11(t+1,o)
- B111(t,o) :
- produce ^(up_angle111(t,o))I1(0.8,0)L(1,11)L(0,t)L(0,t)L(0,t)I1(1,0)I1(1,0)L(1,11)L(0,t)B111(t+2,o)
- B1111(t,o) :
- produce ^(up_angle1111(t,o))I1(1,0)L(1,11)I1(1,0)L(1,11)L(0,t)L(0,t)L(0,t)L(0,t)B1111(t+3,o)
- B3(t,o) :
- produce ^(up_angle(t,o))I1(0.8,0)L(1,t)L(0,t)I1(0.8,0)L(0,t)I1(0.8,0)L(0,t)I1(0.8,0)L(0,t)B3(t+1,o)
- L(t,n) :
- # ages the leaf. If too old, removes
- if t < leafduration : produce L(t+1,n)
- else: produce *
- # Increment radius of internodes
- @O(r) --> @O(r+radinc)
- I(s,r) --> I(s,r+radinc)
- _(r) --> _(r+radinc)
- I1(s,r) --> I(s,r)
- homomorphism:
- I(a,r) --> F(a,r)
- L(t,o) :
- phi = 100 # phyllotactic angle
- col = 2 # color is choosen according to age
- produce [/+(phi)^(90);(col)~l(2)][/+(phi)&(90);(col)~l(1)]
- endlsystem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement