Skip to content

Instantly share code, notes, and snippets.

@telliott99
Created November 19, 2018 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telliott99/916bc75a73e515968debe48ef418d738 to your computer and use it in GitHub Desktop.
Save telliott99/916bc75a73e515968debe48ef418d738 to your computer and use it in GitHub Desktop.
from math import *
# requires x != 0
def radial(x,y):
r = (x**2 + y**2)**0.5
t = atan(1.0*y/x)
return r,t
def cartesian(r,t):
x = cos(t) * r
y = sin(t) * r
return x,y
def power(x,y,n):
r,t = radial(x,y)
r = r**n
t = t*n
x,y = cartesian(r,t)
return round(x,2), round(y,2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment