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
def draw1(x0, n):
angle = 360 / n
P = []
P.append(x0)
for i in range(n):
x = rotation(P[i], angle, deg=True)
P.append(x)
return P
%matplotlib inline
import matplotlib.pyplot as plt
x0 = [0, 1]
n = 5
P = draw1(x0, 5)
plt.figure(figsize=(6,6))
plt.plot(np.array(P)[:, 0], np.array(P)[:, 1])
plt.show()
x0 = [0, 1]
n = 7
P = draw1(x0, n)
plt.figure(figsize=(6,6))
plt.plot(np.array(P)[:, 0], np.array(P)[:, 1])
plt.show()