def cart2polar(x, y, degrees=True):
"""
Convert cartesian X and Y to polar RHO and THETA.
:param x: x cartesian coordinate
:param y: y cartesian coordinate
:param degrees: True = return theta in degrees, False = return theta in
radians. [default: True]
:return: r, theta
"""
rho = ma.sqrt(x ** 2 + y ** 2)
theta = ma.arctan2(y, x)
if degrees:
theta *= (180 / math.pi)
return rho, theta
评论列表
文章目录