Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Phyllotaxis in Python
%matplotlib inline
from math import cos, sin, sqrt, pi
import numpy as np
import matplotlib.pyplot as plt
# golden angle definition
ga = 360/((1+sqrt(5))/2)**2
# initialize random array
a = np.zeros((1000, 2))
# update the positions of each point
for i in range(len(a)):
a[i] = [
(sqrt(i)*cos((i*ga)/180*pi)),
(sqrt(i)*sin((i*ga)/180*pi)),
]
# plot the distribution
plt.scatter(*a.T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment