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
评论列表
文章目录