def test_set(): a = Quaternion() assert a.x == 0 assert a.y == 0 assert a.z == 0 assert a.w == 1 a.set(x, y, z, w) assert a.x == x assert a.y == y assert a.z == z assert a.w == w
def test_normalize_length_length_sq(): a = Quaternion(x, y, z, w) assert a.length() != 1 assert a.length_sq() != 1 a.normalize() assert a.length() == 1 assert a.length_sq() == 1 a.set(0, 0, 0, 0) assert a.length_sq() == 0 assert a.length() == 0 a.normalize() assert a.length_sq() == 1 assert a.length() == 1
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
def test_clone(): a = Quaternion().clone() assert a.x == 0 assert a.y == 0 assert a.z == 0 assert a.w == 1 b = a.set(x, y, z, w).clone() assert b.x == x assert b.y == y assert b.z == z assert b.w == w