MCPcopy Index your code
hub / github.com/ManimCommunity/manim / apply_complex_function

Method apply_complex_function

manim/mobject/mobject.py:1486–1526  ·  view source on GitHub ↗

Applies a complex function to a :class:`Mobject`. The x and y Point3Ds correspond to the real and imaginary parts respectively. Example ------- .. manim:: ApplyFuncExample class ApplyFuncExample(Scene): def construct(self):

(
        self,
        function: Callable[[complex], complex],
        *,
        about_point: Point3DLike | None = None,
        about_edge: Vector3DLike | None = None,
    )

Source from the content-addressed store, hash-verified

1484 return self
1485
1486 def apply_complex_function(
1487 self,
1488 function: Callable[[complex], complex],
1489 *,
1490 about_point: Point3DLike | None = None,
1491 about_edge: Vector3DLike | None = None,
1492 ) -> Self:
1493 """Applies a complex function to a :class:`Mobject`.
1494 The x and y Point3Ds correspond to the real and imaginary parts respectively.
1495
1496 Example
1497 -------
1498
1499 .. manim:: ApplyFuncExample
1500
1501 class ApplyFuncExample(Scene):
1502 def construct(self):
1503 circ = Circle().scale(1.5)
1504 circ_ref = circ.copy()
1505 circ.apply_complex_function(
1506 lambda x: np.exp(x*1j)
1507 )
1508 t = ValueTracker(0)
1509 circ.add_updater(
1510 lambda x: x.become(circ_ref.copy().apply_complex_function(
1511 lambda x: np.exp(x+t.get_value()*1j)
1512 )).set_color(BLUE)
1513 )
1514 self.add(circ_ref)
1515 self.play(TransformFromCopy(circ_ref, circ))
1516 self.play(t.animate.set_value(TAU), run_time=3)
1517 """
1518
1519 def R3_func(point):
1520 x, y, z = point
1521 xy_complex = function(complex(x, y))
1522 return [xy_complex.real, xy_complex.imag, z]
1523
1524 return self.apply_function(
1525 R3_func, about_point=about_point, about_edge=about_edge
1526 )
1527
1528 def reverse_points(self) -> Self:
1529 for mob in self.family_members_with_points():

Callers

nothing calls this directly

Calls 1

apply_functionMethod · 0.95

Tested by

no test coverage detected