Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.53 KB | None | 0 0
  1.  #!/usr/bin/env python3
  2.  
  3. import matplotlib
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6.  
  7.  
  8.  
  9. class Point:
  10.     def __init__(self, p_a, p_b):
  11.         self.a = p_a
  12.         self.b = p_b
  13.  
  14.     def __str__(self):
  15.         return "(" + str(self.a) + ", " + str(self.b) + ")"
  16.  
  17.     def __repr__(self):
  18.         return "(" + str(self.a) + ", " + str(self.b) + ")"
  19.  
  20.  
  21. # Data for plotting
  22. k = 1
  23. n = 64 * k
  24. a = [np.cos(i * 2 * np.pi / n) for i in range(n)]
  25. b = [np.sin(i * 2 * np.pi / n) for i in range(n)]
  26.  
  27. points = {key: Point(a[key], b[key]) for key in range(n)}
  28.  
  29. fig, ax = plt.subplots()
  30. line, = ax.plot(a, b, 'o')
  31.  
  32. x = []
  33. for i in range(n):
  34.     if i < n / 8 - 2:
  35.         x.append(i)
  36.     elif i < n / 8 + 4:
  37.         continue
  38.     elif i == n / 8 + 4:
  39.         x.append(n / 8 - 2)
  40.         x.append(n / 8)
  41.         x.append(n / 8 + 2)
  42.         x.append(n / 8 - 1)
  43.         x.append(n / 8 + 1)
  44.         x.append(n / 8 + 3)
  45.         x.append(n / 8 + 4)
  46.     elif i < 3 * n / 8 - 3:
  47.         x.append(i)
  48.     elif i < 3 * n / 8 + 3:
  49.         continue
  50.     elif i == 3 * n / 8 + 3:
  51.         x.append(3 * n / 8 - 3)
  52.         x.append(3 * n / 8 - 1)
  53.         x.append(3 * n / 8 + 1)
  54.         x.append(3 * n / 8 - 2)
  55.         x.append(3 * n / 8)
  56.         x.append(3 * n / 8 + 2)
  57.         x.append(i)
  58.     elif i < 7 * n / 8 - 3:
  59.         x.append(i)
  60.     elif i < 7 * n / 8 + 5:
  61.         continue
  62.     elif i == 7 * n / 8 + 5:
  63.         x.append(7 * n / 8 - 3)
  64.         x.append(7 * n / 8 + 3)
  65.         x.append(7 * n / 8 - 2)
  66.         x.append(7 * n / 8)
  67.         x.append(7 * n / 8 + 2)
  68.         x.append(7 * n / 8 - 1)
  69.         x.append(7 * n / 8 + 1)
  70.         x.append(7 * n / 8 + 4)
  71.         x.append(i)
  72.     else:
  73.         x.append(i)
  74.  
  75. x_a = [points[i].a for i in x] + [points[0].a]
  76. x_b = [points[i].b for i in x] + [points[0].b]
  77. ax.plot(x_a, x_b)
  78.  
  79. y = []
  80. for i in range(n):
  81.     if i < 5 * n / 8 - 2:
  82.         y.append(i)
  83.     elif i < 5 * n / 8 + 4:
  84.         continue
  85.     elif i == 5 * n / 8 + 4:
  86.         y.append(5 * n / 8 - 2)
  87.         y.append(5 * n / 8)
  88.         y.append(5 * n / 8 + 2)
  89.         y.append(5 * n / 8 - 1)
  90.         y.append(5 * n / 8 + 1)
  91.         y.append(5 * n / 8 + 3)
  92.         y.append(i)
  93.     else:
  94.         y.append(i)
  95.  
  96. y_a = [points[i].a for i in y] + [points[0].a]
  97. y_b = [points[i].b for i in y] + [points[0].b]
  98. #ax.plot(y_a, y_b)
  99. counter = 0
  100. for i in range(n):
  101.     if x[i] != y[i]:
  102.         counter += 1
  103.         print(x[i], y[i])
  104.  
  105. print("different edges count", counter)
  106. ax.grid()
  107.  
  108. #fig.savefig("test.png")
  109. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement