Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- def dots(nmax, a=None, rot=None):
- r3o2, to_rads = np.sqrt(3)/2., np.pi/180.
- if a == None: a = 1.0
- if rot == None: rot=0.0
- i = np.arange(-nmax, nmax+1)
- I, J = np.meshgrid(i, i)
- keep = np.abs(I+J) <= nmax
- I, J = [thing[keep].flatten() for thing in (I, J)]
- x, y = a*(I + 0.5*J), a*r3o2*J
- c, s = [f(to_rads*rot) for f in (np.cos, np.sin)]
- return x*c - y*s, y*c + x*s
- rat = np.sqrt(13./7)
- A = dots(12)
- B, C = dots(10, rat, 5.209), dots(10, rat, 11.218)
- plt.figure()
- plt.subplot(1, 2, 1)
- plt.scatter([0], [0], s=400, c='black', edgecolor='none')
- plt.scatter(A[0], A[1], s=200, c='none', edgecolor='black')
- plt.scatter(B[0], B[1], s=60, c='black', edgecolor='none')
- plt.xlim(-0.5, 14)
- plt.ylim(-0.5, 14)
- plt.gca().set_aspect('equal')
- plt.title('(5, 6) <-> (5, 3) (5.209 deg)', fontsize=16)
- plt.subplot(1, 2, 2)
- plt.scatter([0], [0], s=400, c='black', edgecolor='none')
- plt.scatter(A[0], A[1], s=200, c='none', edgecolor='black')
- plt.scatter(C[0], C[1], s=60, c='black', edgecolor='none')
- plt.xlim(-0.5, 14)
- plt.ylim(-0.5, 14)
- plt.gca().set_aspect('equal')
- plt.title('(6, 5) <-> (5, 3) (11.218 deg)', fontsize=16)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment