def get_sph_cor(x,y,z): #using radian
lon=0
if(x==0 and y>0):
lon=PI/2
elif(x==0 and y<0):
lon=3*PI/2
elif(x==0 and y==0):
print ("error")
return
elif(x>0 and y==0):
lon=0
elif(x>0 and y>0):
lon=math.atan(float(y)/float(x))
elif(x>0 and y<0):
lon=2*PI+math.atan(float(y)/float(x))
elif(x<0 and y==0):
lon=PI
elif(x<0 and y>0):
lon=PI+math.atan(float(y)/float(x))
elif(x<0 and y<0):
lon=PI+math.atan(float(y)/float(x))
lat=PI/2-math.acos(z/1.0)
return lon,lat
评论列表
文章目录