Created
July 21, 2021 14:24
-
-
Save duhaime/d8b6e6c03da9264547815ee9d334edba to your computer and use it in GitHub Desktop.
Phyllotaxis in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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