yazdmich

Untitled

Oct 8th, 2014
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. from PIL import Image
  2. from math import radians, degrees, cos, sin
  3. from IPython.core import display
  4. from io import BytesIO
  5. midx, midy = 361, 361
  6. img = Image.new( 'RGB', (722,722), "white") # create a new white image
  7. pixels = img.load() # create the pixel map
  8.  
  9. class cart:
  10.     def __init__(self, m, x, y, z):
  11.         self.m = zeros(m, dtype = int16)
  12.         self.x = zeros(x, dtype = int16)
  13.         self.y = zeros(y, dtype = int16)
  14.         self.z = zeros(z, dtype = int16)
  15. maps = array([cart((720, 720), 720, 720, 720) for x in range(720)])
  16.  
  17. dir = '.'
  18. for q in range(1,721):
  19.     for s in range(361):
  20.         for t in range(1,361):
  21.             #print(s,t,q)
  22.             maps[q].x[t] = (cos(radians(s)) * t) + midx
  23.             maps[q].y[t] = (sin(radians(t)) * s) + midy
  24.             maps[q].z[t] = s
  25.             x = maps[q].x[t] - midx
  26.             z = maps[q].z[t]
  27.             x = round(cos(radians(q/2)) * x - sin(radians(q/2)) * z)
  28.             maps[q].x[t] = x + midx
  29.             pixels[abs(int(maps[q].x[t])), abs(int(maps[q].y[t]))] = (int(maps[q].x[t]), int(maps[q].y[t]), 100)
  30.     print(q)
  31.     img = img.rotate(180)
  32.     img.save(dir+'/image'+str(q)+'.png', 'png')
  33.     img = Image.new( 'RGB', (722,722), "white")
  34.     pixels = img.load()
Advertisement
Add Comment
Please, Sign In to add comment