def _Angle(u, v):
"""Return angle between two vectors.
Args:
u: (float, float)
v: (float, float)
Returns:
float - angle in radians between u and v, where
it is +/- depending on sign of ux * vy - uy * vx
"""
(ux, uy) = u
(vx, vy) = v
costheta = (ux * vx + uy * vy) / \
(math.sqrt(ux ** 2 + uy ** 2) * math.sqrt(vx ** 2 + vy ** 2))
if costheta > 1.0:
costheta = 1.0
if costheta < -1.0:
costheta = -1.0
theta = math.acos(costheta)
if ux * vy - uy * vx < 0.0:
theta = -theta
return theta
评论列表
文章目录