def xyzToSpherical(x,y,z):
'''
Convert x,y,z to spherical coordinates
@param x: Cartesian coordinate x
@param y: Cartesian coordinate y
@param z: Cartesian coordinate z
@return numpy array of latitude,longitude, and radius
'''
radius = np.sqrt(x**2 + y**2 + z**2)
theta = np.rad2deg(np.arctan2(y,x))
phi = np.rad2deg(np.arccos(z/radius))
# lon = (theta + 180) % 360 - 180
# lon = (theta + 360) % 360
lon = theta
lat = 90 - phi
return np.array([lat,lon,radius]).T
评论列表
文章目录