Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cycles of regular polygons
# http://math.stackexchange.com/q/1798630/35416
def polycycle(n, collected):
cf = CyclotomicField(n)
zeta = cf.gen()
corner = -2*(1 + zeta)/(1 + zeta + 1 + 1/zeta)
center = [corner*zeta^k for k in range(n)]
gra = []
for m in range(3, 7):
mn = (m - 2)*n
if mn & 1: continue
for part in Partitions(mn//2, length=m):
for perm in set(map(tuple, CyclicPermutations(part))):
z = 0
for k in perm:
z = z + 1
z = -z * zeta^k
if z: continue
# print(perm)
corners = []
overlap = False
for k in perm:
f = lambda p: -(p + 2) * zeta^k
corners = center + map(f, corners)
if any(CC(c*c.conjugate()).real() < 1 for c in corners):
overlap = True
break
if overlap: continue
polys = Graphics()
for k, poly in enumerate(matrix(cf, m, n, corners).rows()):
polys += polygon2d(map(CC, poly),
title="{} regular {}-gons".format(m, n),
color=hue(float(k/float(m)), 0.5, 0.5),
edgecolor="black")
polys.axes(False)
gra.append(polys)
if gra:
print "{} regular {}-gons".format(m, n)
break
collected.append(gra)
collected = []
for i in range(3, 25):
polycycle(i, collected)
maxlen = max(map(len, collected))
for row in collected:
while len(row) < maxlen:
row.append(Graphics())
graphics_array(collected).show(axes=False, title=None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.