## task 1 class Polar(object): def __init__(self,r,phi): self.r = r self.phi = phi def getX(self): return self.r*math.cos(self.phi) def getY(self): return self.r*math.sin(self.phi) def distance(otherPoint): ##use equation to figure out ## otherPolar(r,phi) return sqrt(self.r**2 + otherPoint.r**2-2*self.r*otherPoint.r*math.cos(self.phi-otherPoint.phi)) def toPoint(): ##not sure what this one does return self.getX,self.getY def add(aPoint): newX = getX + aPoint.getX newY = getY + aPoint.getY newr = sqrt(newX**2 + newY**2) newphi = math.tan(newY/newX) ##find equation ##recog will be tricky part return Polar(newr,newphi) def mult(aPoint): ##same as add... dif equation return Polar(self.r*aPoint.r,self.phi+aPoint.phi) def equal(otherPoint): ##use modulous of 2pi return True
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question