Skip to content

Instantly share code, notes, and snippets.

@shak360
Last active September 24, 2018 20:27
Show Gist options
  • Save shak360/c458a4d2b5cab4e66ff44becc8db888b to your computer and use it in GitHub Desktop.
Save shak360/c458a4d2b5cab4e66ff44becc8db888b to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as pl
import numpy as n
def F(i):
m=i
j=2
while j<=i/j:
if i%j==0:
m=j
i/=j
else:
j+=1
if m<i:
m=i
return int(m)
def P(i,x,u):
b = n.linspace(0,2*n.pi)
if i<2:
s = n.linalg.norm(u)
pl.fill(x[0]+s*n.cos(b), x[1]+s*n.sin(b),'k')
else:
m=F(i)
a=n.pi/m/2
R=n.array([[n.cos(a), -n.sin(a)],[n.sin(a), n.cos(a)]])
p=R@u
for j in range(m):
P(i/m, x+p/2, (n.sin(a*2)/2)*p)
p=n.linalg.matrix_power(R,4)@p
for i in range(100):
pl.subplot(10,10,i+1)
pl.axis('equal')
pl.axis('off')
P(i+1, [0,0], [0,1])
pl.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment