def test_quaternion_conversions(self, rng): # noqa: F811 """ Bidirectional rotor - quaternion test. This needs work but is a reasonable start """ from clifford.tools.g3 import rotor_to_quaternion, quaternion_to_rotor from clifford.tools.g3c import random_rotation_rotor for i in range(1000): rotor = random_rotation_rotor(rng=rng) quaternion = rotor_to_quaternion(rotor) rotor_return = quaternion_to_rotor(quaternion) testing.assert_almost_equal(rotor.value, rotor_return.value)
def test_quaternion_conversions(self): """ Bidirectional rotor - quaternion test. This needs work but is a reasonable start """ from clifford.g3c import layout from clifford.tools.g3 import rotor_to_quaternion, quaternion_to_rotor from clifford.tools.g3c import random_rotation_rotor for i in range(1000): rotor = random_rotation_rotor() quaternion = rotor_to_quaternion(rotor) rotor_return = quaternion_to_rotor(quaternion) testing.assert_almost_equal(rotor.value, rotor_return.value)
def test_find_rotor_aligning_vectors(self, rng): # noqa: F811 """ Currently fails, needs to be dug into """ from clifford.g3c import layout e1 = layout.blades['e1'] e2 = layout.blades['e2'] from clifford.tools.g3 import random_euc_mv, random_rotation_rotor, rotor_align_vecs u_list = [random_euc_mv(rng=rng) for i in range(50)] for i in range(100): r = random_rotation_rotor(rng=rng) v_list = [r * u * ~r for u in u_list] r_2 = rotor_align_vecs(u_list, v_list) print(r_2) print(r) testing.assert_almost_equal(r.value, r_2.value)
def test_find_rotor_aligning_vectors(self): """ Currently fails, needs to be dug into """ from clifford.g3c import layout e1 = layout.blades['e1'] e2 = layout.blades['e2'] from clifford.tools.g3 import random_euc_mv, random_rotation_rotor, rotor_align_vecs u_list = [random_euc_mv() for i in range(50)] for i in range(100): r = random_rotation_rotor() v_list = [r*u*~r for u in u_list] r_2 = rotor_align_vecs(u_list, v_list) print(r_2) print(r) testing.assert_almost_equal(r.value, r_2.value)
def test_rotation_matrix_conversions(self): """ Bidirectional rotor - rotation matrix test. This needs work but is a reasonable start """ from clifford.g3c import layout, up, down from clifford.tools.g3 import rotation_matrix_to_rotor, rotor_to_rotation_matrix from clifford.tools.g3c import random_rotation_rotor, random_conformal_point, apply_rotor for i in range(1000): rotor = random_rotation_rotor() # Check that we can map up and back Rmat = rotor_to_rotation_matrix(rotor) rotor_return = rotation_matrix_to_rotor(Rmat) testing.assert_almost_equal(rotor.value, rotor_return.value) # Check that the rotations do the same thing A = random_conformal_point() B = down(apply_rotor(A, rotor)).value[1:4] C = Rmat @ down(A).value[1:4] np.testing.assert_almost_equal(B, C)
def test_rotation_matrix_conversions(self): """ Bidirectional rotor - rotation matrix test. This needs work but is a reasonable start """ from clifford.g3c import layout, up, down from clifford.tools.g3 import rotation_matrix_to_rotor, rotor_to_rotation_matrix from clifford.tools.g3c import random_rotation_rotor, random_conformal_point, apply_rotor for i in range(1000): rotor = random_rotation_rotor() # Check that we can map up and back Rmat = rotor_to_rotation_matrix(rotor) rotor_return = rotation_matrix_to_rotor(Rmat) testing.assert_almost_equal(rotor.value, rotor_return.value) # Check that the rotations do the same thing A = random_conformal_point() B = down(apply_rotor(A, rotor)).value[1:4] C = Rmat @ down(A).value[1:4] np.testing.assert_almost_equal(B, C)