Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  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 = 1 # maximum number of branching order
  6. radinc = 0.15 # increment of radius through time
  7. rand = 0.001
  8. maxduration = lambda order : int(5./(order+1))+5 # life time of an apex
  9. branch_angle = lambda order : 20 # branching angle
  10. branch_angle2 = lambda order : 30 # branching angle
  11. # number of axe at a ramification
  12. nb_axes = lambda order : rd.randint(2,4) if order > 2 else rd.randint(4-int((order+1)/2),5-int((order+1)/2))
  13. up_angle3 = lambda t,order : -35
  14. up_angle = lambda t,order : -30
  15. up_angle2 = lambda t,order : -25
  16. up_angle1 = lambda t,order : -20 # up angle for lateral branches
  17. up_angle11 = lambda t,order : -15
  18. up_angle111 = lambda t,order : -10
  19. up_angle1111 = lambda t,order : -7
  20. up_angle0 = lambda t,order : -4
  21. # number total of iterations of the system
  22. nbiter = sum([maxduration(o) for o in xrange(maxorder+1)])
  23.  
  24. module A # represent trunk apical meristem
  25. module B # represent apical meristem of lateral branches
  26. module L # whorl of leaf
  27. module I # Internode
  28.  
  29.  
  30. Axiom: _(1.5)@GcI(0,1)A(0,0)
  31.  
  32. derivation length: nbiter
  33. production:
  34. A(t,o) :
  35. if t < maxduration(o):
  36. # simply produces a metamer and ages the apex
  37. produce I(2,0.3)A(t+1,o)
  38. else:
  39. # produce a whorl of sympodial branches
  40. nbaxe = nb_axes(o)
  41. q = 0
  42. if q == 0:
  43. for i in range(14):
  44. nproduce [/(130*i/5)B3(0,8)]
  45. nproduce [/(90*i/5)B(0,10)]
  46. nproduce [/(130*i/5)B2(0,8)]
  47. q = q+1
  48. if q == 1:
  49. for i in range(9):
  50. nproduce [/(360*i/5)B1(0,6)]
  51. nproduce [/(120*i/5)B11(0,4)]
  52. nproduce [/(240*i/5)B111(0,2)]
  53. q = q+1
  54. if q == 2:
  55. for i in range(12):
  56. nproduce [/(135*i/5)B1111(0,1)]
  57. if q == 3:
  58.  
  59. for i in range(3):
  60. nproduce [/(60*i/5)B0(0,1)]
  61. produce @O(2);(5)
  62.  
  63.  
  64. B(t,o) :
  65. 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)
  66. B0(t,o) :
  67. 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)
  68. B2(t,o) :
  69. 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)
  70. B1(t,o) :
  71. 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)
  72. B11(t,o) :
  73. 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)
  74. B111(t,o) :
  75. 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)
  76. B1111(t,o) :
  77. 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)
  78. B3(t,o) :
  79. 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)
  80.  
  81. L(t,n) :
  82. # ages the leaf. If too old, removes
  83. if t < leafduration : produce L(t+1,n)
  84. else: produce *
  85.  
  86. # Increment radius of internodes
  87. @O(r) --> @O(r+radinc)
  88. I(s,r) --> I(s,r+radinc)
  89. _(r) --> _(r+radinc)
  90. I1(s,r) --> I(s,r)
  91.  
  92.  
  93. homomorphism:
  94. I(a,r) --> F(a,r)
  95.  
  96. L(t,o) :
  97. phi = 100 # phyllotactic angle
  98. col = 2 # color is choosen according to age
  99. produce [/+(phi)^(90);(col)~l(2)][/+(phi)&(90);(col)~l(1)]
  100. endlsystem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement