Skip to content

Instantly share code, notes, and snippets.

@duhaime
Created July 21, 2021 14:24
Show Gist options
  • Save duhaime/d8b6e6c03da9264547815ee9d334edba to your computer and use it in GitHub Desktop.
Save duhaime/d8b6e6c03da9264547815ee9d334edba to your computer and use it in GitHub Desktop.
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