This post is Private. Only a writer or those who know its URL can access this post.

Article information
Show article in Markdown
Report article
Help us understand the problem. What is going on with this article?

# プログラミング問題集解答例（問３４）

```import numpy as np
def rotation(x, t, deg = False):
if deg == True:
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()
```

Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away