Movement¶
声明
这一页翻译自elteoremadebeethoven的 manim_3feb_docs
Homotopy¶
-
class
manimlib.animation.movement.
Homotopy
(homotopy: Callable[[float, float, float, float], Sequence[float]], mobject: Mobject, **kwargs)¶ Homotopy is a function from (x, y, z, t) to (x’, y’, z’)
HomotopyExample¶
class HomotopyExample(Scene):
def construct(self):
def plane_wave_homotopy(x, y, z, t):
norm = get_norm([x, y])
tau = interpolate(5, -5, t) + norm/FRAME_X_RADIUS
alpha = sigmoid(tau)
return [x, y + 0.5*np.sin(2*np.pi*alpha)-t*SMALL_BUFF/2, z]
mobjects = VGroup(
Text("Text").scale(3),
Square(),
).arrange(RIGHT, buff=2)
self.add(mobjects)
self.play(
*[Homotopy(
plane_wave_homotopy,
mob
) for mob in mobjects]
)
self.wait(0.3)
ComplexHomotopy¶
-
class
manimlib.animation.movement.
ComplexHomotopy
(complex_homotopy: Callable[[complex, float], Sequence[float]], mobject: Mobject, **kwargs)¶ Given a function form (z, t) -> w, where z and w are complex numbers and t is time, this animates the state over time
ComplexHomotopyExample¶
class ComplexHomotopyExample(Scene):
def construct(self):
def complex_func(z: complex, t: float) -> complex:
return interpolate(z, z**3, t)
mobjects = VGroup(
Text("Text"),
Square(side_length=1),
).arrange(RIGHT, buff=2)
self.add(mobjects)
self.play(
*[ComplexHomotopy(
complex_func,
mob
) for mob in mobjects]
)
self.wait(0.3)
PhaseFlow¶
-
class
manimlib.animation.movement.
PhaseFlow
(function: Callable[[np.ndarray], np.ndarray], mobject: Mobject, **kwargs)¶
PhaseFlowExample¶
class PhaseFlowExample(Scene):
def construct(self):
def func(t):
return t*0.5*RIGHT
mobjects=VGroup(
Text("Text").scale(3),
Square(),
).arrange(RIGHT,buff=2)
self.play(
*[PhaseFlow(
func, mob,
run_time = 2,
)for mob in mobjects]
)
self.wait()
MoveAlongPath¶
-
class
manimlib.animation.movement.
MoveAlongPath
(mobject: Mobject, path: Mobject, **kwargs)¶
MoveAlongPathExample¶
class MoveAlongPathExample(Scene):
def construct(self):
line=Line(ORIGIN,RIGHT*FRAME_WIDTH,buff=1)
line.move_to(ORIGIN)
dot=Dot()
dot.move_to(line.get_start())
self.add(line,dot)
self.play(
MoveAlongPath(dot,line)
)
self.wait(0.3)