Advertisement
atm-irbis

Cannabis in Python

Feb 10th, 2013
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. from math import sin,cos
  3.  
  4. func = lambda phi:(1+sin(phi))*(1+0.9*cos(8*phi))*(1+0.1*cos(24*phi))
  5.  
  6. class Cannabis(object):
  7.     def __init__(self,func):
  8.         "Инициализация конопли. Ее функция уже определена"
  9.         self.coord = []
  10.         self.x = []
  11.         self.y = []
  12.         phi = 0
  13.         while phi<360:
  14.             r = func(phi)
  15.             crt = (phi,r)
  16.             self.coord.append(crt)
  17.             phi+=0.01
  18.         for n,m in self.coord:
  19.             xx = m * cos(n)
  20.             yy = m * sin(n)
  21.             self.x.append(xx)
  22.             self.y.append(yy)
  23.     def graph(self):
  24.         plt.plot(self.x,self.y,'g--')
  25.         plt.show()
  26.  
  27. o = Cannabis(func)
  28. o.graph()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement