Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sin,cos
- class ToPolar:
- def __init__(self):
- self.x = []
- self.y = []
- def convert(self,r,phi):
- self.x.append(r*cos(phi))
- self.y.append(r*sin(phi))
- @property
- def x(self):
- return self.x
- @property
- def y(self):
- return self.y
- def cannabis(phi):
- return 1+sin(phi)*(1+0.9*cos(8*phi))*(1+0.1*cos(24*phi))
- class Cannabis:
- def __init__(self):
- self.tp = ToPolar()
- self.__start__()
- def __start__(self):
- phi = 0.0
- while phi < 360.0:
- y = cannabis(phi)
- self.tp.convert(y,phi)
- phi+=0.01
- def plot(self):
- '''
- plotting cannabis
- '''
- import matplotlib.pyplot as plt
- plt.plot(self.tp.x,self.tp.y,'go')
- plt.show()
- x = Cannabis()
- x.plot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement