필로탁시스(Phyllotaxis) 패턴이란?
식물학 시간을 떠올려 보면, 필로탁시스(엽序學)는 식물 줄기 위에서 꽃, 잎, 씨앗이 배열되는 방식을 의미합니다. 이 배열은 피보나치 나선(Fibonacci Spiral)에서 발견되는 형태와 놀라울 정도로 유사합니다.
피보나치 나선은 피보나치 수열을 기반으로 하며, 파스칼의 삼각형과 비슷한 규칙성을 따르는 숫자들의 집합입니다. 피보나치 수열은 다음과 같습니다.
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 ...
즉, 피보나치 수열의 각 숫자는 바로 앞에 있는 두 숫자의 합이라는 특징을 가지고 있습니다.
자연 속의 피보나치 나선
인간은 본능적으로 주변 사물을 이해하기 위해 대칭성과 패턴을 찾곤 합니다. 흥미롭게도 우리 눈은 스스로 인식하지 못한 채 피보나치 수열을 계속 보고 있습니다. 대표적인 예가 바로 해바라기 꽃대인데, 해바라기 중앙의 씨앗 배열이 정확히 피보나치 나선 형태를 따르고 있습니다.
구현 결과


해바라기 나선(Sunflower Spiral)
예제 코드
아래 코드는 파이썬의 turtle 모듈과 math 모듈을 활용하여 필로탁시스 패턴을 화면에 그리는 예제입니다. 황금각(golden angle)인 약 137.508도를 회전 각도로 사용하는 것이 핵심입니다.
import math
import turtle
def PhyllotacticPattern( 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(25)
turtle.forward(100)
turtle.left(45)
turtle.forward(100)
turtle.left(140)
turtle.forward(100)
turtle.left(45)
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
PhyllotacticPattern( 200, 160, 137.508, 4, 10 )
turtle.exitonclick() # lets you x out of the window when outside of idle
실행 결과

위 프로그램에서 색상을 커스터마이징하거나 일부 매개변수 값을 조정하기만 해도, 전혀 다른 느낌의 아름다운 패턴을 얻을 수 있습니다.
