math_utils.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def get_sph_theta(coords, normal):
    # The angle (theta) with respect to the normal (J), is the arccos
    # of the dot product of the normal with the normalized coordinate
    # vector.

    res_normal = resize_vector(normal, coords)

    # check if the normal vector is normalized
    # since arccos requires the vector to be normalised
    res_normal = normalize_vector(res_normal)

    tile_shape = [1] + list(coords.shape)[1:]

    J = np.tile(res_normal,tile_shape)

    JdotCoords = np.sum(J*coords,axis=0)

    with np.errstate(invalid='ignore'):
        ret = np.arccos( JdotCoords / np.sqrt(np.sum(coords**2,axis=0)))

    ret[np.isnan(ret)] = 0

    return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号