misc.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:seis_tools 作者: romaguir 项目源码 文件源码
def cartesian_to_spherical(x,degrees=True,normalize=False):
   '''
   Coverts a cartesian vector in R3 to spherical coordinates
   '''
   r = np.linalg.norm(x)
   theta = np.arccos(x[2]/r)
   phi = np.arctan2(x[1],x[0])

   if degrees:
      theta = np.degrees(theta)
      phi = np.degrees(phi)

   s = [r,theta,phi]

   if normalize:
      s /= np.linalg.norm(s)

   return s
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号