sphere_transforms_numpy.py 文件源码

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

项目:spherical_image_editing 作者: henryseg 项目源码 文件源码
def angles_from_sphere(pts):
    """equirectangular projection, ie. map from sphere in R^3 to (0, 2*pi) x (-pi/2, pi/2)
    Parameters
    ----------
    pts : array_like (3,...)
        pts[0,...], pts[1,...], and pts[2,...] are x,y, and z coordinates
    Returns
    -------
    out : ndarray (2,...)
        pts transformed from x,y,z to longitude,latitude
    """
    pts = np.asarray(pts) #turn into an ndarray if necessary
    x,y,z = pts[0], pts[1], pts[2]
    out = np.empty((2,) + pts.shape[1:])
    #longitude:
    out[0] = np.arctan2(y,x)
    out[0] %= 2*pi #wrap negative values around the circle to positive
    #latitude:
    r = np.hypot(x,y)
    out[1] = np.arctan2(z,r)
    return out
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号