def compute_angle(pt0, pt1, pt2):
"""
Given 3 points, compute the cosine of the angle from pt0
:type pt0: numpy.array
:type pt1: numpy.array
:type pt2: numpy.array
:return: cosine of angle
"""
a = pt0 - pt1
b = pt0 - pt2
return (np.sum(a * b)) / (np.linalg.norm(a) * np.linalg.norm(b))
评论列表
文章目录