Exemple #1
0
def quaternion_and_vector_to_rotor(quaternion, vector):
    """
    Takes in a quaternion and a vector and returns a conformal rotor that
    implements the transformation
    """
    rotation = quaternion_to_rotor(quaternion)
    translation = generate_translation_rotor(vector[0] * e1 +
                                             vector[1] * e2 * vector[3] * e3)
    return translation * rotation
Exemple #2
0
def quaternion_and_vector_to_rotor(quaternion, vector):
    """
    Takes in a quaternion and a vector and returns a conformal rotor that
    implements the transformation
    """
    rotation = quaternion_to_rotor(quaternion)
    translation = generate_translation_rotor(
        vector[0] * e1 + vector[1] * e2 * vector[3] * e3)
    return translation * rotation
Exemple #3
0
 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)
Exemple #4
0
 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_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
     e1 = layout.blades['e1']
     e2 = layout.blades['e2']
     rotor = e1 * e2
     print(rotor)
     quaternion = rotor_to_quaternion(rotor)
     print(quaternion)
     rotor_return = quaternion_to_rotor(quaternion)
     print(rotor_return)
     testing.assert_almost_equal(rotor.value, rotor_return.value)