vector_shortcuts.py 文件源码

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

项目:blmath 作者: bodylabs 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号