mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 22:13:30 +08:00
Factored out topics/complex_numbers constructs to the appropriate places with mobject/, animation/ and scene/
This commit is contained in:
@ -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,
|
||||
|
@ -12,8 +12,10 @@ from utils.config_ops import digest_config
|
||||
from utils.iterables import adjacent_pairs
|
||||
from utils.paths import path_along_arc
|
||||
from utils.paths import straight_path
|
||||
from utils.config_ops import instantiate
|
||||
from utils.rate_functions import smooth
|
||||
from utils.rate_functions import squish_rate_func
|
||||
from utils.space_ops import complex_to_R3
|
||||
|
||||
class 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/2
|
||||
|
@ -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 *
|
||||
|
@ -1,23 +1,12 @@
|
||||
from constants import *
|
||||
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.creation import ShowCreation
|
||||
from animation.movement import Homotopy
|
||||
from animation.movement import SmoothedVectorizedHomotopy
|
||||
from animation.transform import ApplyPointwiseFunction
|
||||
from animation.transform import MoveToTarget
|
||||
from mobject.coordinate_systems import NumberPlane
|
||||
from mobject.coordinate_systems import ComplexPlane
|
||||
from mobject.svg.tex_mobject import TexMobject
|
||||
from mobject.svg.tex_mobject import TextMobject
|
||||
from mobject.types.vectorized_mobject import VGroup
|
||||
from 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_R3
|
||||
|
||||
class 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)
|
||||
|
||||
|
||||
|
||||
|
@ -17,3 +17,6 @@ def initials(name, sep_values = [" ", "_"]):
|
||||
|
||||
def camel_case_initials(name):
|
||||
return filter(lambda c : c.isupper(), name)
|
||||
|
||||
def complex_string(complex_num):
|
||||
return filter(lambda c : c not in "()", str(complex_num))
|
||||
|
Reference in New Issue
Block a user