Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import matplotlib
- import matplotlib.pyplot as plt
- import numpy as np
- class Point:
- def __init__(self, p_a, p_b):
- self.a = p_a
- self.b = p_b
- def __str__(self):
- return "(" + str(self.a) + ", " + str(self.b) + ")"
- def __repr__(self):
- return "(" + str(self.a) + ", " + str(self.b) + ")"
- # Data for plotting
- k = 1
- n = 64 * k
- a = [np.cos(i * 2 * np.pi / n) for i in range(n)]
- b = [np.sin(i * 2 * np.pi / n) for i in range(n)]
- points = {key: Point(a[key], b[key]) for key in range(n)}
- fig, ax = plt.subplots()
- line, = ax.plot(a, b, 'o')
- x = []
- for i in range(n):
- if i < n / 8 - 2:
- x.append(i)
- elif i < n / 8 + 4:
- continue
- elif i == n / 8 + 4:
- x.append(n / 8 - 2)
- x.append(n / 8)
- x.append(n / 8 + 2)
- x.append(n / 8 - 1)
- x.append(n / 8 + 1)
- x.append(n / 8 + 3)
- x.append(n / 8 + 4)
- elif i < 3 * n / 8 - 3:
- x.append(i)
- elif i < 3 * n / 8 + 3:
- continue
- elif i == 3 * n / 8 + 3:
- x.append(3 * n / 8 - 3)
- x.append(3 * n / 8 - 1)
- x.append(3 * n / 8 + 1)
- x.append(3 * n / 8 - 2)
- x.append(3 * n / 8)
- x.append(3 * n / 8 + 2)
- x.append(i)
- elif i < 7 * n / 8 - 3:
- x.append(i)
- elif i < 7 * n / 8 + 5:
- continue
- elif i == 7 * n / 8 + 5:
- x.append(7 * n / 8 - 3)
- x.append(7 * n / 8 + 3)
- x.append(7 * n / 8 - 2)
- x.append(7 * n / 8)
- x.append(7 * n / 8 + 2)
- x.append(7 * n / 8 - 1)
- x.append(7 * n / 8 + 1)
- x.append(7 * n / 8 + 4)
- x.append(i)
- else:
- x.append(i)
- x_a = [points[i].a for i in x] + [points[0].a]
- x_b = [points[i].b for i in x] + [points[0].b]
- ax.plot(x_a, x_b)
- y = []
- for i in range(n):
- if i < 5 * n / 8 - 2:
- y.append(i)
- elif i < 5 * n / 8 + 4:
- continue
- elif i == 5 * n / 8 + 4:
- y.append(5 * n / 8 - 2)
- y.append(5 * n / 8)
- y.append(5 * n / 8 + 2)
- y.append(5 * n / 8 - 1)
- y.append(5 * n / 8 + 1)
- y.append(5 * n / 8 + 3)
- y.append(i)
- else:
- y.append(i)
- y_a = [points[i].a for i in y] + [points[0].a]
- y_b = [points[i].b for i in y] + [points[0].b]
- #ax.plot(y_a, y_b)
- counter = 0
- for i in range(n):
- if x[i] != y[i]:
- counter += 1
- print(x[i], y[i])
- print("different edges count", counter)
- ax.grid()
- #fig.savefig("test.png")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement