Guest User

Untitled

a guest
Jul 15th, 2014
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # Failed attempt at penrose tiling
  2. # MRG 07/2014
  3. import numpy as np
  4.  
  5. # 5 vectors pointing toward the points of a pentagon
  6. dimensions = 5
  7. starters = np.linspace(0, 2 * np.pi, dimensions + 1)[:-1]
  8. bVectors = np.array([(np.cos(t), np.sin(t)) for t in starters])
  9.  
  10. # A uniform grid of points b/t -10 to 10 in 1000 steps
  11. xs, ys = np.mgrid[-10:10:1000j, -10:10:1000j]
  12.  
  13. # A place to accumulate the computed values
  14. bGrid = np.zeros((1000, 1000, dimensions))
  15.  
  16. for i in range(dimensions):
  17.     bGrid[:, :, i] = np.rint((bVectors[i, 0] * xs) + (bVectors[i, 1] * ys))
  18.  
  19. flattened = np.sum(bGrid, axis=2)
  20.  
  21. # Plotting etc
  22. from pylab import cool, figure, imshow, savefig, show
  23.  
  24. figure(figsize=(12, 12))
  25. imshow(flattened)
  26. cool()
  27. savefig("attempt.png")
  28. show()
Advertisement
Add Comment
Please, Sign In to add comment