-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_5_tree_leaf.py
50 lines (41 loc) · 1.4 KB
/
example_5_tree_leaf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#L-SYSTEM DEFINITION
# Turtle orientation : H,U,L vectors (Heading, Up, Left)
# ^ : Left or Right around U
# & : pitch down or up around L
# | : roll left or right around H
# $ : force L to be horizontal (x,y,0)
# { : begin fill
# } : end fill
# ° : mark the turtle position
from math import *
ALPHABET=['A','B','C','F','G','L','!','^','&','$','|','[',']','{','}','°']
PARAMETERS=['l','w','t','s','r']
#leaf Constants
la=5 # initial length - main segment
ra=1.1 # growth rate - main segment
lb=1 # initial length - lateral segment
rb=1.3 # growth rate - lateral segment
pd=1 # growth potential decrement
b=40*pi/180
#tree constants
d1=94.74*pi/180 # divergence angle 1
d2=132.63*pi/180 # divergence angle 2
a=18.95*pi/180 # branching angle
lr=1.15 # elongation rate
vr=1.45 #width increase rate
c=45*pi/180 #leaf angle
#Tree Production
AXIOME_T='!(1.9)F(30)|(pi/4)A()L()'
PRODUCTION_T=['A():True→!(1.5*vr)F(30)[&(a)!(vr)F(20)A()$()[^(c)L()][^(-c)L()]L()]|(d1)[&(a)!(vr)F(20)A()$()[^(c)L()][^(-c)L()]L()]|(d2)[&(a)!(vr)F(20)A()$()[^(c)L()][^(-c)L()]L()]',
'F(l):True→F(l*lr)',
'!(w):True→!(w*vr)'
]
#Leaf Production
AXIOME_L='{°C(0)}'
PRODUCTION_L=['C(t):True→G(la,ra)[^(-a)B(t)°][C(t+1)][^(a)B(t)°]',
'B(t):t>0→G(lb,rb)B(t-pd)',
'G(s,r):True→G(s*r,r)'
]
#Productions
AXIOMES=[AXIOME_T,AXIOME_L]
PRODUCTIONS=[PRODUCTION_T,PRODUCTION_L]