def test_factorise(self, obj_gen): n_repeats = 50 for i in range(n_repeats): X1 = obj_gen() basis, scale = X1.factorise() for b in basis: gpres = grades_present(b, 0.0001) assert gpres == {1} new_blade = (reduce(lambda a, b: a ^ b, basis) * scale) try: npt.assert_almost_equal(new_blade.value, X1.value, 3) except: print(X1) print(new_blade) npt.assert_almost_equal(new_blade.value, X1.value, 3)
def test_factorise(self): n_repeats = 50 for obj_gen in self.object_generators: print(obj_gen.__name__) for i in range(n_repeats): X1 = obj_gen() basis, scale = X1.factorise() for b in basis: gpres = grades_present(b, 0.0001) assert len(gpres) == 1 assert gpres[0] == 1 new_blade = (reduce(lambda a, b: a ^ b, basis) * scale) try: np.testing.assert_almost_equal(new_blade.value, X1.value, 3) except: print(X1) print(new_blade) np.testing.assert_almost_equal(new_blade.value, X1.value, 3)
def interpret_multivector_as_object(mv): """ Takes an input multivector and returns what kind of object it is -1 -> not a blade 0 -> a 1 vector but not a point 1 -> a euclidean point 2 -> a conformal point 3 -> a point pair 4 -> a circle 5 -> a line 6 -> a sphere 7 -> a plane """ g_pres = grades_present(mv, 0.00000001) if len(g_pres) != 1: # Definitely not a blade return -1 grade = g_pres[0] if grade == 1: # This can now either be a euc mv or a conformal point or something else if mv(e123) == mv: return 1 # Euclidean point elif np.sum(np.abs((mv**2).value)) < 0.00000001: return 2 # Conformal point else: return 0 # Unknown mv elif mv.isBlade(): if grade == 2: return 3 # Point pair elif grade == 3: # Line or circle if abs(mv[e123]) > epsilon: return 4 # Circle else: return 5 # Line elif grade == 4: # Sphere or plane if abs(((mv * I5) | ninf)[0]) > epsilon: return 7 # Plane else: return 6 # Sphere else: return -1
def interpret_multivector_as_object(mv): """ Takes an input multivector and returns what kind of object it is -1 -> not a blade 0 -> a 1 vector but not a point 1 -> a euclidean point 2 -> a conformal point 3 -> a point pair 4 -> a circle 5 -> a line 6 -> a sphere 7 -> a plane """ g_pres = grades_present(mv, 0.00000001) if len(g_pres) != 1: # Definitely not a blade return -1 grade = g_pres[0] if grade == 1: # This can now either be a euc mv or a conformal point or something else if mv(e123) == mv: return 1 # Euclidean point elif np.sum(np.abs((mv**2).value)) < 0.00000001: return 2 # Conformal point else: return 0 # Unknown mv elif mv.isBlade(): if grade == 2: return 3 # Point pair elif grade == 3: # Line or circle if abs(mv[e123]) > epsilon: return 4 # Circle else: return 5 # Line elif grade == 4: # Sphere or plane if abs(((mv*I5)|ninf)[0]) > epsilon: return 7 # Plane else: return 6 # Sphere else: return -1