A community-maintained Python framework for creating mathematical animations.
Factored out topics/complex_numbers constructs to the appropriate places with mobject/, animation/ and scene/
Grant Sanderson73514a2d7787
diff --git a/animation/movement.py b/animation/movement.pyindex 8842240f5..201ed7796 100644--- a/animation/movement.py+++ b/animation/movement.py@@ -34,6 +34,18 @@ class SmoothedVectorizedHomotopy(Homotopy):Homotopy.update_submobject(self, submob, start, alpha)submob.make_smooth()+class ComplexHomotopy(Homotopy):+ def __init__(self, complex_homotopy, mobject, **kwargs):+ """+ Complex Hootopy a function Cx[0, 1] to C+ """+ def homotopy(event):+ x, y, z, t = event+ c = complex_homotopy((complex(x, y), t))+ return (c.real, c.imag, z)+ Homotopy.__init__(self, homotopy, mobject, *args, **kwargs)++class PhaseFlow(Animation):CONFIG = {"virtual_time" : 1,diff --git a/animation/transform.py b/animation/transform.pyindex 38778c28a..c684e91e2 100644--- a/animation/transform.py+++ b/animation/transform.py@@ -12,8 +12,10 @@ from utils.config_ops import digest_configfrom utils.iterables import adjacent_pairsfrom utils.paths import path_along_arcfrom utils.paths import straight_path+from utils.config_ops import instantiatefrom utils.rate_functions import smoothfrom utils.rate_functions import squish_rate_func+from utils.space_ops import complex_to_R3class Transform(Animation):CONFIG = {@@ -162,6 +164,21 @@ class ApplyMatrix(ApplyPointwiseFunction):return np.dot(p, transpose)ApplyPointwiseFunction.__init__(self, func, mobject, **kwargs)+class ComplexFunction(ApplyPointwiseFunction):+ def __init__(self, function, mobject, **kwargs):+ if "path_func" not in kwargs:+ self.path_func = path_along_arc(+ np.log(function(complex(1))).imag+ )+ ApplyPointwiseFunction.__init__(+ self,+ lambda (x, y, z) : complex_to_R3(function(complex(x, y))),+ instantiate(mobject),+ **kwargs+ )++###+class CyclicReplace(Transform):CONFIG = {"path_arc" : np.pi/2diff --git a/big_ol_pile_of_manim_imports.py b/big_ol_pile_of_manim_imports.pyindex 06de7344f..884209355 100644--- a/big_ol_pile_of_manim_imports.py+++ b/big_ol_pile_of_manim_imports.py@@ -61,12 +61,12 @@ from scene.zoomed_scene import *from once_useful_constructs.arithmetic import *from once_useful_constructs.combinatorics import *+from once_useful_constructs.complex_transformation_scene import *from once_useful_constructs.counting import *from once_useful_constructs.fractals import *from once_useful_constructs.graph_theory import *from once_useful_constructs.light import *-from topics.complex_numbers import *from topics.functions import *from topics.graph_scene import *from topics.matrix import *diff --git a/topics/complex_numbers.py b/once_useful_constructs/complex_transformation_scene.pysimilarity index 79%rename from topics/complex_numbers.pyrename to once_useful_constructs/complex_transformation_scene.pyindex 3d7370d29..efbbe21b7 100644--- a/topics/complex_numbers.py+++ b/once_useful_constructs/complex_transformation_scene.py@@ -1,23 +1,12 @@from constants import *-from animation.animation import Animation-from animation.creation import ShowCreation-from animation.movement import Homotopyfrom animation.movement import SmoothedVectorizedHomotopyfrom animation.transform import ApplyPointwiseFunctionfrom animation.transform import MoveToTarget-from mobject.coordinate_systems import NumberPlanefrom mobject.coordinate_systems import ComplexPlane-from mobject.svg.tex_mobject import TexMobject-from mobject.svg.tex_mobject import TextMobjectfrom mobject.types.vectorized_mobject import VGroupfrom scene.scene import Scene-from utils.config_ops import digest_config-from utils.config_ops import instantiate-from utils.paths import path_along_arc-from utils.space_ops import R3_to_complex-from utils.space_ops import complex_to_R3class ComplexTransformationScene(Scene):CONFIG = {@@ -167,35 +156,6 @@ class ComplexTransformationScene(Scene):*added_anims)-##### Unsure about what comes under here...--def complex_string(complex_num):- return filter(lambda c : c not in "()", str(complex_num))--class ComplexFunction(ApplyPointwiseFunction):- def __init__(self, function, mobject = ComplexPlane, **kwargs):- if "path_func" not in kwargs:- self.path_func = path_along_arc(- np.log(function(complex(1))).imag- )- ApplyPointwiseFunction.__init__(- self,- lambda (x, y, z) : complex_to_R3(function(complex(x, y))),- instantiate(mobject),- **kwargs- )--class ComplexHomotopy(Homotopy):- def __init__(self, complex_homotopy, mobject = ComplexPlane, **kwargs):- """- Complex Hootopy a function Cx[0, 1] to C- """- def homotopy(event):- x, y, z, t = event- c = complex_homotopy((complex(x, y), t))- return (c.real, c.imag, z)- Homotopy.__init__(self, homotopy, mobject, *args, **kwargs)-diff --git a/utils/strings.py b/utils/strings.pyindex bfed3b668..54eaae3ec 100644--- a/utils/strings.py+++ b/utils/strings.py@@ -16,4 +16,7 @@ def initials(name, sep_values = [" ", "_"]):])def camel_case_initials(name):- return filter(lambda c : c.isupper(), name)\ No newline at end of file+ return filter(lambda c : c.isupper(), name)++def complex_string(complex_num):+ return filter(lambda c : c not in "()", str(complex_num))