vector_shortcuts.py 文件源码

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

项目:blmath 作者: bodylabs 项目源码 文件源码
def angle(v1, v2, look): # FIXME pylint: disable=unused-argument
    '''
    Compute the unsigned angle between two vectors.

    Returns a number between 0 and 180.

    '''
    import math

    # TODO https://bodylabs.atlassian.net/projects/GEN/issues/GEN-1
    # As pylint points out, we are not using `look` here. This method is
    # supposed to be giving the angle between two vectors when viewed along a
    # particular look vector, squashed into a plane. The code here is
    # returning the angle in 3-space, which might be a reasonable function to
    # have, but is not workable for computing the angle between planes as
    # we're doing in bodylabs.measurement.anatomy.Angle.

    dot = normalize(v1).dot(normalize(v2))
    # Dot product sometimes slips past 1 or -1 due to rounding.
    # Can't acos(-1.00001).
    dot = max(min(dot, 1), -1)

    return math.degrees(math.acos(dot))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号