• API
• FAQ
• Tools
• Archive
SHARE
TWEET Untitled a guest May 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random as rd
2.
3. leafduration = 4 # life time of a leaf
4. leafold =      2 # age at which a leaf is considered as old
5. maxorder =     4 # maximum number of branching order
7.
8. maxduration = lambda order : int(5./(order+1))+5  # life time of an apex
9. branch_angle = lambda order : 8 # branching angle
10. # number of axe at a ramification
11. nb_axes = lambda order : rd.randint(2,4) if order > 2 else rd.randint(4-int((order+1)/2),5-int((order+1)/2))
12. up_angle = lambda t,order : -5        # up angle for lateral branches
13.
14. # number total of iterations of the system
15. nbiter = sum([maxduration(o) for o in xrange(maxorder+1)])
16.
17. module A # represent trunk apical meristem
18. module B # represent apical meristem of lateral branches
19. module L # whorl of leaf
20. module I # Internode
21.
22.
23. Axiom: _(0.05)@GcI(0.5,0.05)A(0,0)
24.
25. derivation length: nbiter
26. production:
27. A(t,o) :
28.   if t < maxduration(o):
29.      # simply produces a metamer and ages the apex
30.      produce I(1,0.1)L(0,t)A(t+1,o)
31.   else:
32.       # produce a whorl of sympodial branches
33.       nbaxe = nb_axes(o)
34.       for i in xrange(nbaxe):
35.         nproduce [/(360*i/nbaxe)&(branch_angle(o))B(0,o+1)]
36.
37.
38. B(t,o) :
39.   if t < maxduration(o):
40.      # simply produces a metamer and ages the apex
41.      # reorient smoothly the branch toward the up
42.      produce ^(up_angle(t,o))I(1,0.1)L(0,t)B(t+1,o)
43.   else:
44.       # produce a whorl of sympodial branches
45.       nbaxe = nb_axes(o)
46.       for i in xrange(nbaxe):
47.         nproduce [/(360*i/nbaxe)&(branch_angle(o))B(0,o+1)]
48.
49. L(t,n) :
50.   # ages the leaf. If too old, removes
51.   if t < leafduration :  produce L(t+1,n)
52.   else:   produce *
53.
54. # Increment radius of internodes
57.
58. homomorphism:
59. I(a,r) --> F(a,r)
60.
61. L(t,p) :
62.     phi = 0 if p % 2 == 0 else 90  # phyllotactic angle
63.     col = 4 if t >= leafold else 2 # color is choosen according to age
64.     produce [/(phi)^(120);(col)~l(1)][/(phi)&(120);(col)~l(1)]
65.
66. endlsystem
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top