As you would do in any other language... Transform the coordinates.
from math import *
def transform(x, o):
r = hypot(x[0] - o[0], x[1] - o[1])
phi = atan2(x[1] - o[1], x[0] - o[0])
if phi < 0: phi = phi + 2*pi # if you want phi in [0, 2pi]
return r, phi
class ExactSolution(Expression):
def __init__(self, origin, a):
self.origin, self.a = origin, a
def eval(self, values, x):
r, phi = transform (x, origin)
values[0] = r**self.a*sin(self.a*phi)
return