A community-maintained Python framework for creating mathematical animations.
Noted some problems with VectorspaceScene
Grant Sanderson2c2a69b14f9b
diff --git a/scene/vector_space_scene.py b/scene/vector_space_scene.pyindex cd42b2e5c..5ae1fba80 100644--- a/scene/vector_space_scene.py+++ b/scene/vector_space_scene.py@@ -37,6 +37,12 @@ Y_COLOR = RED_CZ_COLOR = BLUE_D+# TODO: Much of this scene type seems dependent on the coordinate system chosen.+# That is, being centered at the origin with grid units corresponding to the+# arbitrary space units. Change it!+#+# Also, methods I would have thought of as getters, like coords_to_vector, are+# actually doing a lot of animating.class VectorScene(Scene):CONFIG = {"basis_vector_stroke_width": 6@@ -65,6 +71,14 @@ class VectorScene(Scene):self.add(axes)self.freeze_background()+ def get_vector(self, numerical_vector, **kwargs):+ return Arrow(+ self.plane.coords_to_point(0, 0),+ self.plane.coords_to_point(*numerical_vector[:2]),+ buff=0,+ **kwargs+ )+def add_vector(self, vector, color=YELLOW, animate=True, **kwargs):if not isinstance(vector, Arrow):vector = Vector(vector, color=color, **kwargs)@@ -281,10 +295,10 @@ class LinearTransformationScene(VectorScene):}def setup(self):+ # The has_already_setup attr is to not break all the old Scenesif hasattr(self, "has_already_setup"):returnself.has_already_setup = True- # ^This is to not break all the old Scenesself.background_mobjects = []self.foreground_mobjects = []self.transformable_mobjects = []@@ -321,6 +335,7 @@ class LinearTransformationScene(VectorScene):def add_background_mobject(self, *mobjects):self.add_special_mobjects(self.background_mobjects, *mobjects)+ # TODO, this conflicts with Scene.add_foredef add_foreground_mobject(self, *mobjects):self.add_special_mobjects(self.foreground_mobjects, *mobjects)@@ -427,6 +442,9 @@ class LinearTransformationScene(VectorScene):def apply_matrix(self, matrix, **kwargs):self.apply_transposed_matrix(np.array(matrix).T, **kwargs)+ def apply_inverse(self, matrix, **kwargs):+ self.apply_matrix(np.linalg.inv(matrix), **kwargs)+def apply_transposed_matrix(self, transposed_matrix, **kwargs):func = self.get_transposed_matrix_transformation(transposed_matrix)if "path_arc" not in kwargs: