def polar3d(x):
"""
Polar coordinate representation of a three-dimensional vector.
@param x: vector (i.e. rank one array)
@return: polar coordinates (radius and polar angles)
"""
if x.shape != (3,):
raise ValueError(x)
r = norm(x)
theta = numpy.arccos(x[2] / r)
phi = numpy.arctan2(x[1], x[0])
return numpy.array([r, theta, phi])
评论列表
文章目录