def test_general_logarithm_TR(self): for i in range(5): # R = generate_rotation_rotor(0.5, e1, e2).normal() # T = generate_translation_rotor(e3 + 7 * e2 - e1).normal() # V = (T*R).normal() biv_true = random_bivector() V = general_exp(biv_true).normal() biv = general_logarithm(V) V_rebuilt = (general_exp(biv)).normal() C1 = random_point_pair() C2 = ( V *C1 *~V).normal() C3 = (V_rebuilt *C1 *~V_rebuilt).normal() np.testing.assert_almost_equal(C2.value, C3.value, 2)
def test_general_logarithm_TR(self): for i in range(5): # R = generate_rotation_rotor(0.5, e1, e2).normal() # T = generate_translation_rotor(e3 + 7 * e2 - e1).normal() # V = (T*R).normal() biv_true = random_bivector() V = general_exp(biv_true).normal() biv = general_logarithm(V) V_rebuilt = (general_exp(biv)).normal() C1 = random_point_pair() C2 = (V * C1 * ~V).normal() C3 = (V_rebuilt * C1 * ~V_rebuilt).normal() npt.assert_almost_equal(C2.value, C3.value, 2)
def test_general_logarithm_scaling(self): # Check we can reverse scaling for i in range(50): scale = 0.5 + np.random.rand() biv = -np.log(scale ) *e45 /2 R = general_exp(biv).normal() biv_2 = general_logarithm(R) np.testing.assert_almost_equal(biv.value, biv_2.value)
def full_conformal_biv_params_to_rotor(biv_params): """ Converts the bivector parameters for a general conformal rotor into the rotor """ biv = full_conformal_biv_params_to_biv(biv_params) R = general_exp(biv).normal() return R
def test_general_logarithm_conformal(self, obj_gen): for i in range(10000): X = obj_gen() Y = obj_gen() R = rotor_between_objects(X, Y) biv = general_logarithm(R) R_recon = general_exp(biv).normal() npt.assert_almost_equal(R.value, R_recon.value, 4)
def test_general_logarithm_scaling(self): # Check we can reverse scaling for i in range(50): scale = 0.5 + np.random.rand() biv = -np.log(scale) * e45 / 2 R = general_exp(biv).normal() biv_2 = general_logarithm(R) npt.assert_almost_equal(biv.value, biv_2.value)
def TRS_biv_params_to_rotor(biv_params): """ Converts the bivector parameters for a general TRS rotor into the rotor """ biv = TRS_biv_params_to_biv(biv_params) R = general_exp(biv).normal() return R
def test_general_logarithm_translation(self): # Check we can reverse translation for i in range(50): t = random_euc_mv() biv = ninf * t / 2 R = general_exp(biv).normal() biv_2 = general_logarithm(R) npt.assert_almost_equal(biv.value, biv_2.value)
def test_general_logarithm_translation(self): # Check we can reverse translation for i in range(50): t = random_euc_mv() biv = ninf * t /2 R = general_exp(biv).normal() biv_2 = general_logarithm(R) np.testing.assert_almost_equal(biv.value, biv_2.value)
def interpolate_rotors(R_n_plus_1, R_n, interpolation_fraction): """ Interpolates all conformal type rotors From :cite:`wareham-interpolation` and :cite:`log-of-rotors`. """ if interpolation_fraction < np.finfo(float).eps: return R_n delta_R = R_n_plus_1 * ~R_n delta_bivector = general_logarithm(delta_R)(2) R_n_lambda = general_exp(interpolation_fraction * delta_bivector) * R_n return R_n_lambda
def test_general_logarithm_TS(self): for i in range(5): scale = 0.5 + np.random.rand() t = random_euc_mv() S = generate_dilation_rotor(scale) T = generate_translation_rotor(t) V = (T * S).normal() biv = general_logarithm(V) V_rebuilt = (general_exp(biv)).normal() C1 = random_point_pair() C2 = (V * C1 * ~V).normal() C3 = (V_rebuilt * C1 * ~V_rebuilt).normal() npt.assert_almost_equal(C2.value, C3.value, 5)
def test_general_logarithm_TS(self): for i in range(5): scale = 0.5 +np.random.rand() t = random_euc_mv() S = generate_dilation_rotor(scale) T = generate_translation_rotor(t) V = ( T *S).normal() biv = general_logarithm(V) V_rebuilt = (general_exp(biv)).normal() C1 = random_point_pair() C2 = ( V *C1 *~V).normal() C3 = (V_rebuilt *C1 *~V_rebuilt).normal() np.testing.assert_almost_equal(C2.value, C3.value, 5)
def test_general_logarithm_conformal(self): object_generators = [random_point_pair, random_line, random_circle, random_plane] # object_generators = [random_sphere] for obj_gen in object_generators: print(obj_gen.__name__) for i in range(10000): X = obj_gen() Y = obj_gen() R = rotor_between_objects(X, Y) biv = general_logarithm(R) R_recon = general_exp(biv).normal() np.testing.assert_almost_equal(R.value, R_recon, 3)
def test_general_logarithm_TRS(self): for i in range(5): scale = 0.5 + np.random.rand() S = generate_dilation_rotor(scale) R = generate_rotation_rotor(0.5, e1, e2) T = generate_translation_rotor(e3 + 7 * e2 - e1) V = (T * R * S).normal() biv = general_logarithm(V) V_rebuilt = general_exp(biv).normal() biv2 = general_logarithm(V) C1 = random_point_pair() C2 = (V * C1 * ~V).normal() C3 = (V_rebuilt * C1 * ~V_rebuilt).normal() npt.assert_almost_equal(C2.value, C3.value)
def interpolate_rotors(R_n_plus_1, R_n, interpolation_fraction): """ Interpolates all conformal type rotors Mesh Vertex Pose and Position Interpolation using Geometric Algebra Rich Wareham and Joan Lasenby and Square Root and Logarithm of Rotors Leo Dorst and Robert Valkenburg """ if interpolation_fraction < np.finfo(float).eps: return R_n delta_R = R_n_plus_1 * ~R_n delta_bivector = general_logarithm(delta_R)(2) R_n_lambda = general_exp(interpolation_fraction * delta_bivector) * R_n return R_n_lambda
def test_general_logarithm_TRS(self): for i in range(5): scale = 0.5 + np.random.rand() S = generate_dilation_rotor(scale) R = generate_rotation_rotor(0.5, e1, e2) T = generate_translation_rotor(e3 + 7* e2 - e1) V = (T * R * S).normal() biv = general_logarithm(V) V_rebuilt = general_exp(biv).normal() biv2 = general_logarithm(V) C1 = random_point_pair() C2 = (V * C1 * ~V).normal() C3 = (V_rebuilt * C1 * ~V_rebuilt).normal() np.testing.assert_almost_equal(C2.value, C3.value)