def test_angle_to(): a = Quaternion() b = Quaternion().set_from_euler(Euler(0, pi, 0)) c = Quaternion().set_from_euler(Euler(0, pi * 2, 0)) assert a.angle_to(a) == 0 assert a.angle_to(b) == pi assert a.angle_to(c) == 0
def test_rotate_towards(): a = Quaternion() b = Quaternion().set_from_euler(Euler(0, pi, 0)) c = Quaternion() half_pi = pi * 0.5 a.rotate_towards(b, 0) assert a.equals(a) is True a.rotate_towards(b, pi * 2) # test overshoot assert a.equals(b) is True a.set(0, 0, 0, 1) a.rotate_towards(b, half_pi) assert a.angle_to(c) - half_pi <= eps