Patró de filotaxi en Python | Una unitat de botànica algorítmica

Patró de filotaxi en Python | Una unitat de botànica algorítmica

La filotaxi/filotaxia és la disposició de les fulles a la tija d'una planta i les espirals filotàctiques formen una classe distintiva de patrons a la natura. La paraula en si prové del grec phullon que significa "fulla" i taxis que significa "arranjament". Els arranjaments filotàxics florals bàsics inclouen:

1. Filotaxi en espiral -

En la filotaxia espiral, els òrgans florals individuals es creen en un interval de temps regular amb el mateix angle divergent. L'angle divergent en una flor amb filotaxia espiral s'aproxima a 137,5 graus, cosa que és indicatiu d'un patró que segueix un

Sèrie de Fibonacci

.La imatge següent mostra els patrons de filotaxi en espiral amb patrons en espiral en sentit horari i en sentit contrari.

Patró de filotaxi en Python | Una unitat de botànica algorítmica


Aspectes importants a tenir en compte:

  1. Les sèries de Fibonacci solen descriure espirals que es troben a la natura. Es calcula com una sèrie on el parell de números anterior suma al número següent de la sèrie. La sèrie és 1 1 2 3 5 8 13 21 34 55 89 … .
  2. En realitat, hi ha un conjunt d'espirals en sentit horari i un conjunt en sentit contrari a les agulles del rellotge.
  3. Les espirals d'òrgans florals segueixen un conjunt de numeradors i denominadors de nombres de Fibonacci compensats (1/2 1/3 2/5 3/8 5/13 8/21 13/34...). El numerador és el nombre de vegades o girs al voltant de l'eix per tornar a l'origen d'iniciació. El denominador indica el nombre d'òrgans iniciats durant els girs. Per tant, un 2/5 indicaria 2 voltes al voltant de l'eix i 5 òrgans per tornar a l'origen.
  4. ex. - En el pi tenim (2 3) (5 3) i (5 8) fil·lotaxes en capituli les parelles trobades són (21 34) (55 34) (55 89) i (89 144) i en pinyes amb escates hexagonals les tres bessones (8 13 21) es troben en funció de la mida (34 21)1 o segons la mida dels exemplars (34 13 21) .
  5. La prevalença de la seqüència de Fibonacci a la filotaxi sovint es coneix com "el misteri de la filotaxi".


Altres tipus d'arranjaments filotàxics florals són:

2. Filotaxi espiral 3. Filotaxi simple espiral 4. Filotaxi espiral complex i 5. Filotaxi irregular

Formació del patró: Resum

La bella disposició de les fulles en algunes plantes anomenada filotaxi obeeix a una sèrie de relacions matemàtiques subtils. Per exemple, les floretes del cap d'un gira-sol formen dues espirals dirigides de manera oposada: 55 d'elles en sentit horari i 34 en sentit contrari. Sorprenentment

  1. Aquests nombres són nombres de Fibonacci consecutius.
  2. Les proporcions dels nombres alternatius de Fibonacci estan donades pels convergents a φ^(-2) on φ és el proporció àuria i es diu que mesuren la fracció de volta entre les fulles successives de la tija d'una planta:
  3. ex.: 1/2 per om i til·ler 1/3 per faig i avellaner 2/5 per roure i poma 3/8 per àlber i rosa 5/13 per salze i ametller, etc.
  4. Cada nova fulla de la tija d'una planta es col·loca en un angle determinat respecte a l'anterior i que aquest angle és constant entre fulles: normalment uns 137,5 graus.

És a dir, si mireu la planta des de dalt i mesureu l'angle format entre una línia dibuixada de la tija a la fulla i una línia corresponent per a la següent fulla, trobareu que generalment hi ha un angle fix anomenat angle de divergència. Aquí ens interessa la filotaxia espiral i codificarem per formar un patró de filotaxia espiral en python mitjançant gràfics de tortuga.

Disseny del Codi

  1. Codificarem dues funcions una per dibuixar el patró de la filotaxia i l'altra per dibuixar els pètals.
  2. Els pètals només s'han de dibuixar després que s'hagi completat el patró de filotaxi. Per tant, cridarem a la funció drawPetal() des de dins de la funció drawPhyllPattern() amb les últimes coordenades x i y visitades després de dibuixar el patró de filotaxi.
  3. La funció drawPetal() dibuixarà els pètals amb les funcions i les característiques de la tortuga Programació de tortugues .

Per codificar el patró de filotaxi hem de seguir aquestes equacions:

 x = r*cos(θ)   
y = r*sin(θ)

r θ can also vary - so the to form phyllotactic pattern we substitutethe cartesian form
by polar form:

r = c*sqrt(n)
θ = n*137.508°
Patró de filotaxi en Python | Una unitat de botànica algorítmica
 Reduces the problem to optimal packing on a disc so   
r = c*sqrt(n) is from the area of the circle
Area = πr² and n fills the Area in some units
c1 * n/π = r² c is 1/sqrt(c1/π)
So r = some constant c * sqrt(n)

Pseudocodi: patró de filotaxi

 IMPORT MODULES ( MATH TURTLE )   

FUNCTION - DrawPhyllotaxisPattern( turtle t length petalstart angle = 137.508 size cspread)
turtleColor('Black')
FillColor(''Orange')
Convert angle to radians (Φ)
initialize ( xcenterycenter ) = ( 00 )
Drawing the Pattern Starts:
For n in Range ( 0t ):
r = cspread * sqrt(n)
θ = n * Φ

x = r * cos(θ) + xcenter
y = r * sin(θ) + ycenter

TURTLE POSITION(xy)
START DRAWING():
if Drawing pattern ends:
DrawFlowerPetals()

FUNCTION - DrawFlowerPetals(Turtle x coordinate y coordinate)
DRAW using Turtle methods

Create Turtle = gfg
Call DrawPhyllotaxisPattern( gfg t length petalstart angle = 137.508 size cspread)

END
Python Pattern A
   import   math   import   turtle   def   drawPhyllPattern  (  turtle     t     petalstart     angle   =   137.508     size   =   2     cspread   =   4   ):      '''print a pattern of circles using spiral phyllotactic data'''   # initialize position   # turtle.pen(outline=1 pencolor='black' fillcolor='orange')   turtle  .  color  (  'black'  )   turtle  .  fillcolor  (  'orange'  )   phi   =   angle   *   (   math  .  pi   /   180.0   )   #we convert to radian   xcenter   =   0.0   ycenter   =   0.0   # for loops iterate in this case from the first value until  < 4 so   for   n   in   range   (  0     t  ):   r   =   cspread   *   math  .  sqrt  (  n  )   theta   =   n   *   phi   x   =   r   *   math  .  cos  (  theta  )   +   xcenter   y   =   r   *   math  .  sin  (  theta  )   +   ycenter   # move the turtle to that position and draw    turtle  .  up  ()   turtle  .  setpos  (  x     y  )   turtle  .  down  ()   # orient the turtle correctly   turtle  .  setheading  (  n   *   angle  )   if   n   >   petalstart  -  1  :   turtle  .  color  (  'yellow'  )   drawPetal  (  turtle     x     y  )   else  :   turtle  .  stamp  ()   def   drawPetal  (  turtle     x     y   ):   turtle  .  penup  ()   turtle  .  goto  (  x     y  )   turtle  .  pendown  ()   turtle  .  color  (  'black'  )   turtle  .  fillcolor  (  'yellow'  )   turtle  .  begin_fill  ()   turtle  .  right  (  20  )   turtle  .  forward  (  70  )   turtle  .  left  (  40  )   turtle  .  forward  (  70  )   turtle  .  left  (  140  )   turtle  .  forward  (  70  )   turtle  .  left  (  40  )   turtle  .  forward  (  70  )   turtle  .  penup  ()   turtle  .  end_fill  ()   # this is needed to complete the last petal   gfg   =   turtle  .  Turtle  ()   gfg  .  shape  (  'turtle'  )   gfg  .  speed  (  0  )   # make the turtle go as fast as possible   drawPhyllPattern  (  gfg     200     160     137.508   )   gfg  .  penup  ()   gfg  .  forward  (  1000  )   
Python Pattern B
   import   math   import   turtle   def   drawPhyllotacticPattern  (   t     petalstart     angle   =   137.508     size   =   2     cspread   =   4   ):      '''print a pattern of circles using spiral phyllotactic data'''   # initialize position   turtle  .  pen  (  outline  =  1     pencolor  =  'black'     fillcolor  =  'orange'  )   # turtle.color('orange')   phi   =   angle   *   (   math  .  pi   /   180.0   )   xcenter   =   0.0   ycenter   =   0.0   # for loops iterate in this case from the first value until  < 4 so   for   n   in   range   (  0     t  ):   r   =   cspread   *   math  .  sqrt  (  n  )   theta   =   n   *   phi   x   =   r   *   math  .  cos  (  theta  )   +   xcenter   y   =   r   *   math  .  sin  (  theta  )   +   ycenter   # move the turtle to that position and draw    turtle  .  up  ()   turtle  .  setpos  (  x     y  )   turtle  .  down  ()   # orient the turtle correctly   turtle  .  setheading  (  n   *   angle  )   if   n   >   petalstart  -  1  :   #turtle.color('yellow')   drawPetal  (  x     y  )   else  :   turtle  .  stamp  ()   def   drawPetal  (   x     y   ):   turtle  .  up  ()   turtle  .  setpos  (  x     y  )   turtle  .  down  ()   turtle  .  begin_fill  ()   #turtle.fill(True)   turtle  .  pen  (  outline  =  1     pencolor  =  'black'     fillcolor  =  'yellow'  )   turtle  .  right  (  20  )   turtle  .  forward  (  100  )   turtle  .  left  (  40  )   turtle  .  forward  (  100  )   turtle  .  left  (  140  )   turtle  .  forward  (  100  )   turtle  .  left  (  40  )   turtle  .  forward  (  100  )   turtle  .  up  ()   turtle  .  end_fill  ()   # this is needed to complete the last petal   turtle  .  shape  (  'turtle'  )   turtle  .  speed  (  0  )   # make the turtle go as fast as possible   drawPhyllotacticPattern  (   200     160     137.508     4     10   )   turtle  .  exitonclick  ()   # lets you x out of the window when outside of idle   

Sortida:

Patrons de filotaxis.

Patró de filotaxi en Python | Una unitat de botànica algorítmica

Crea un qüestionari