Lab2Program.py 文件源码

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

项目:vrep-maze-solver 作者: youralien 项目源码 文件源码
def angle_diff(a, b):
    """ Calculates the difference between angle a and angle b (both should be in radians)
        the difference is always based on the closest rotation from angle a to angle b
        examples:
            angle_diff(.1,.2) -> -.1
            angle_diff(.1, 2*math.pi - .1) -> .2
            angle_diff(.1, .2+2*math.pi) -> -.1
    """
    a = ThetaRange.normalize_angle(a)
    b = ThetaRange.normalize_angle(b)
    d1 = a-b
    d2 = 2*math.pi - math.fabs(d1)
    if d1 > 0:
        d2 *= -1.0
    if math.fabs(d1) < math.fabs(d2):
        return d1
    else:
        return d2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号