def signed_angle(v1, v2, look):
'''
Compute the signed angle between two vectors.
Returns a number between -180 and 180. A positive number indicates a
clockwise sweep from v1 to v2. A negative number is counterclockwise.
'''
# The sign of (A x B) dot look gives the sign of the angle.
# > 0 means clockwise, < 0 is counterclockwise.
sign = np.sign(np.cross(v1, v2).dot(look))
# 0 means collinear: 0 or 180. Let's call that clockwise.
if sign == 0:
sign = 1
return sign * angle(v1, v2, look)
评论列表
文章目录