예제 #1
0
    def test_rotation_matrix_conversions(self, rng):  # noqa: F811
        """
        Bidirectional rotor - rotation matrix test. This needs work but is a reasonable start
        """
        from clifford.g3c import 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(rng=rng)
            # Check that we can map up and back
            Rmat = rotor_to_rotation_matrix(rotor)
            rotor_return = rotation_matrix_to_rotor(Rmat)

            # Check that the rotations do the same thing
            for k in range(10):
                A = random_conformal_point(rng=rng)
                B = down(apply_rotor(A, rotor)).value[1:4]
                C = Rmat @ down(A).value[1:4]
                np.testing.assert_almost_equal(B, C)

                C = down(apply_rotor(A, rotor_return)).value[1:4]
                np.testing.assert_almost_equal(B, C)
예제 #2
0
 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)