import numpy as np
def rotation(x, t, deg = False):
if deg == True:
t = np.deg2rad(t)
a = np.array([[np.cos(t), -np.sin(t)],
[np.sin(t), np.cos(t)]])
ax = np.dot(a, x)
return ax
n = 5
angle = 360 / n
P = []
x0 = [0, 1]
P.append(x0)
for i in range(n):
x = rotation(P[i], angle * 2, deg=True)
P.append(x)
%matplotlib inline
import matplotlib.pyplot as plt
plt.figure(figsize=(6,6))
plt.plot(np.array(P)[:, 0], np.array(P)[:, 1])
plt.show()
plt.figure(figsize=(6,6))
for n in [19]:
angle = 360 / n
P = []
x0 = [0, 1]
P.append(x0)
for i in range(n):
x = rotation(P[i], angle * int(n/2), deg=True)
P.append(x)
plt.plot(np.array(P)[:, 0], np.array(P)[:, 1])
plt.show()
plt.figure(figsize=(6,6))
n = 19
for m in [2, 3, 4, 5, 6, 7, 8, 9, 10]:
angle = 360 / n
P = []
x0 = [0, 1]
P.append(x0)
for i in range(n):
x = rotation(P[i], angle * m, deg=True)
P.append(x)
plt.plot(np.array(P)[:, 0], np.array(P)[:, 1])
plt.show()