Python의 Phyllotaxis 패턴 | 알고리즘 식물학의 단위

Python의 Phyllotaxis 패턴 | 알고리즘 식물학의 단위

Phyllotaxis/phyllotaxy는 식물 줄기의 잎 배열이며 Phyllotactic 나선은 자연에서 독특한 종류의 패턴을 형성합니다. 단어 자체는 '잎'을 의미하는 그리스어 풀론(phullon)과 '배열'을 의미하는 택시(taxi)에서 유래되었습니다. 기본 꽃 필로탁스 배열은 다음과 같습니다.

1. 나선엽축 -

나선형 필로택시에서는 개별 꽃 기관이 동일한 발산 각도를 갖는 규칙적인 시간 간격으로 생성됩니다. 나선형 잎이 있는 꽃의 발산각은 대략 137.5도에 달하며 이는 다음과 같은 패턴을 나타냅니다.

피보나치 수열

.아래 이미지는 시계 방향과 반시계 방향의 나선형 패턴을 모두 갖는 나선형 계통 패턴을 보여줍니다.

Python의 Phyllotaxis 패턴 | 알고리즘 식물학의 단위


참고할 중요 사항:

  1. 피보나치 수열은 일반적으로 자연에서 발견되는 나선을 나타냅니다. 이전 숫자 쌍의 합이 계열의 다음 숫자가 되는 계열로 계산됩니다. 시리즈는 1 1 2 3 5 8 13 21 34 55 89…
  2. 실제로 시계 방향으로 한 세트의 나선이 있고 시계 반대 방향으로 한 세트가 있습니다.
  3. 꽃 기관 나선은 오프셋 피보나치 수(1/2 1/3 2/5 3/8 5/13 8/21 13/34 …)의 분자와 분모 세트를 따릅니다. 분자는 시작 원점으로 돌아가기 위해 축을 중심으로 회전하는 횟수입니다. 분모는 턴 동안 시작된 기관의 수를 나타냅니다. 따라서 2/5는 축을 중심으로 2번 회전하고 5개의 기관이 원점으로 돌아가는 것을 나타냅니다.
  4. 예 - 소나무의 두상에는 (2 3) (5 3) 및 (5 8) 엽상이 있으며 발견된 쌍은 (21 34) (55 34) (55 89) 및 (89 144)이며 육각형 비늘이 있는 파인애플에서는 표본의 크기에 따라 세 쌍 (8 13 21) 또는 (13 21 34)이 발견됩니다.
  5. 엽맥에 피보나치 수열이 널리 퍼져 있는 현상은 흔히 '엽맥의 신비'라고 불립니다.


다른 유형의 꽃 phyllotaxic 배열은 다음과 같습니다.

2. 소용돌이 엽맥 3. 단순 소용돌이 엽맥 4. 복합 소용돌이 엽맥 & 5. 불규칙 엽맥

패턴의 형성 : 요약

필로택시스(phyllotaxis)라고 불리는 일부 식물의 잎의 아름다운 배열은 여러 가지 미묘한 수학적 관계를 따릅니다. 예를 들어 해바라기 머리에 있는 작은 꽃은 두 개의 반대 방향의 나선을 형성합니다. 그 중 55개는 시계 방향이고 34개는 시계 반대 방향입니다. 놀랍게도

  1. 이 숫자는 연속적인 피보나치 수입니다.
  2. 대체 피보나치 수의 비율은 수렴에 의해 Φ^(-2)로 제공됩니다. 여기서 Φ는 황금비율 식물 줄기의 연속적인 잎 사이의 회전 비율을 측정한다고 합니다.
  3. 예: 느릅나무와 린든은 1/2 너도밤나무와 개암나무는 1/3 참나무와 사과는 2/5 포플러와 장미는 3/8 버드나무와 아몬드는 5/13 등
  4. 식물 줄기의 각 새 잎은 이전 잎과 특정 각도로 위치하며 이 각도는 잎 사이에서 일정합니다(보통 약 137.5도).

즉, 식물을 위에서 내려다보며 줄기에서 잎까지 그은 선과 다음 잎의 해당 선 사이에 형성된 각도를 측정하면 일반적으로 발산각이라는 고정된 각도가 있다는 것을 알 수 있습니다. 여기서 우리는 Spiral phyllotaxy에 관심이 있으며 거북이 그래픽을 사용하여 Python에서 Spiral Phyllotaxy 패턴을 형성하도록 코딩할 것입니다.

코드 디자인

  1. 우리는 phyllotaxy 패턴을 그리는 함수와 꽃잎을 그리는 함수 두 개를 코딩할 것입니다.
  2. 꽃잎은 엽상 패턴이 완성된 후에만 그려야 합니다. 따라서 엽상 패턴을 그린 후 마지막 x 및 y 좌표를 방문하여 drawPhyllPattern() 함수 내부에서 drawPetal() 함수를 호출하겠습니다.
  3. drawPetal() 함수는 거북이 함수와 기능을 사용하여 꽃잎을 그립니다. 거북이 프로그래밍 .

phyllotaxis 패턴을 코딩하려면 다음 방정식을 따라야 합니다.

 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°
Python의 Phyllotaxis 패턴 | 알고리즘 식물학의 단위
 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)

유사 코드: 엽상 패턴

 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   

산출:

필로택시 패턴.

Python의 Phyllotaxis 패턴 | 알고리즘 식물학의 단위

퀴즈 만들기