Skip to content

Reference

Core¤

ComplexMap ¤

Construct and animate a complex mapping.

Parameters:

Name Type Description Default
f Square | Polygon | RegularPolygon | Triangle | Circle | Dot | Line

A geometry (or MObject) created using riemapp.geometry or manim.

required
transformation Callable[[float], float]

The complex transformation as a function reference.

required
Source code in riemapp/core.py
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class ComplexMap:
    """
    Construct and animate a complex mapping.

    Args:
        f:
            A geometry (or `MObject`) created using `riemapp.geometry` or `manim`.
        transformation:
            The complex transformation as a function reference.
    """

    def __init__(
        self,
        f: Square | Polygon | RegularPolygon | Triangle | Circle | Dot | Line,
        transformation: Callable[[float], float],
    ) -> None:
        self.f = f
        self.transformation = transformation

    def __repr__(self) -> str:
        return (
            f"ComplexMap(f={self.f!r}, transformation={self.transformation.__name__})"
        )

    def generate_animation(
        self, *, add_numberplane: bool = False, run_time: float = 1.0
    ) -> ComplexMap.Animate:
        """
        Generates a mathematical animation.

        Args:
            add_numberplane:
                Adds NumberPlane to the scene.
            run_time:
                Run time for creating the provided geometry.

        Returns:
            animate:
                A custom manim Scene object
        """
        self.animate = self.Animate(
            self.f,
            self.transformation,
            add_numberplane=add_numberplane,
            run_time=run_time,
        )

        return self.animate

    def render(self, preview: bool = False) -> None:
        """
        Renders the animation.

        Args:
            preview:
                Automatically opens the generated animation.
        """
        if not hasattr(self, "animate"):
            raise ValueError("generate an animation first")

        self.animate.render(preview=preview)

    class Animate(Scene):
        """
        A placeholder class for manim Scene.

        This class is used to construct and generate manim animations programmatically.

        Args:
            f:
                A geometry (or `MObject`) created using `riemapp.geometry` or `manim`.
            transformation:
                The complex transformation as a function reference.
            add_numberplane:
                Adds NumberPlane to the scene.
            run_time:
                Run time for creating the provided geometry.

        """

        def __init__(
            self,
            f: Square | Polygon | RegularPolygon | Triangle | Circle | Dot | Line,
            transformation: Callable[[float], float],
            *,
            add_numberplane: bool = False,
            run_time: float = 1.0,
        ) -> None:
            self.add_numberplane = add_numberplane
            self.run_time = run_time
            self.f = f
            self.transformation = transformation
            super().__init__()

        def __repr__(self) -> str:
            return (
                f"Animate(f={self.f!r}, transformation={self.transformation.__name__})"
            )

        def construct(self) -> None:
            """
            The default manim constructor
            """
            self.add_numberplane and self.add(NumberPlane())
            self.play(Create(self.f, run_time=self.run_time))
            self.play(
                ApplyComplexFunction(self.transformation, self.f),
            )

Animate ¤

Bases: Scene

A placeholder class for manim Scene.

This class is used to construct and generate manim animations programmatically.

Parameters:

Name Type Description Default
f Square | Polygon | RegularPolygon | Triangle | Circle | Dot | Line

A geometry (or MObject) created using riemapp.geometry or manim.

required
transformation Callable[[float], float]

The complex transformation as a function reference.

required
add_numberplane bool

Adds NumberPlane to the scene.

False
run_time float

Run time for creating the provided geometry.

1.0
Source code in riemapp/core.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class Animate(Scene):
    """
    A placeholder class for manim Scene.

    This class is used to construct and generate manim animations programmatically.

    Args:
        f:
            A geometry (or `MObject`) created using `riemapp.geometry` or `manim`.
        transformation:
            The complex transformation as a function reference.
        add_numberplane:
            Adds NumberPlane to the scene.
        run_time:
            Run time for creating the provided geometry.

    """

    def __init__(
        self,
        f: Square | Polygon | RegularPolygon | Triangle | Circle | Dot | Line,
        transformation: Callable[[float], float],
        *,
        add_numberplane: bool = False,
        run_time: float = 1.0,
    ) -> None:
        self.add_numberplane = add_numberplane
        self.run_time = run_time
        self.f = f
        self.transformation = transformation
        super().__init__()

    def __repr__(self) -> str:
        return (
            f"Animate(f={self.f!r}, transformation={self.transformation.__name__})"
        )

    def construct(self) -> None:
        """
        The default manim constructor
        """
        self.add_numberplane and self.add(NumberPlane())
        self.play(Create(self.f, run_time=self.run_time))
        self.play(
            ApplyComplexFunction(self.transformation, self.f),
        )

construct() ¤

The default manim constructor

Source code in riemapp/core.py
119
120
121
122
123
124
125
126
127
def construct(self) -> None:
    """
    The default manim constructor
    """
    self.add_numberplane and self.add(NumberPlane())
    self.play(Create(self.f, run_time=self.run_time))
    self.play(
        ApplyComplexFunction(self.transformation, self.f),
    )

generate_animation(*, add_numberplane=False, run_time=1.0) ¤

Generates a mathematical animation.

Parameters:

Name Type Description Default
add_numberplane bool

Adds NumberPlane to the scene.

False
run_time float

Run time for creating the provided geometry.

1.0

Returns:

Name Type Description
animate Animate

A custom manim Scene object

Source code in riemapp/core.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def generate_animation(
    self, *, add_numberplane: bool = False, run_time: float = 1.0
) -> ComplexMap.Animate:
    """
    Generates a mathematical animation.

    Args:
        add_numberplane:
            Adds NumberPlane to the scene.
        run_time:
            Run time for creating the provided geometry.

    Returns:
        animate:
            A custom manim Scene object
    """
    self.animate = self.Animate(
        self.f,
        self.transformation,
        add_numberplane=add_numberplane,
        run_time=run_time,
    )

    return self.animate

render(preview=False) ¤

Renders the animation.

Parameters:

Name Type Description Default
preview bool

Automatically opens the generated animation.

False
Source code in riemapp/core.py
69
70
71
72
73
74
75
76
77
78
79
80
def render(self, preview: bool = False) -> None:
    """
    Renders the animation.

    Args:
        preview:
            Automatically opens the generated animation.
    """
    if not hasattr(self, "animate"):
        raise ValueError("generate an animation first")

    self.animate.render(preview=preview)

Geometries¤

ArbitraryCurve ¤

Constructs an arbitrary curve.

Parameters:

Name Type Description Default
curve

A curve in the form of a Python function

required
x_range

The (x_min, x_max, x_step) values of the x-axis

required
y_range

The (y_min, y_max, y_step) values of the y-axis

required
Source code in riemapp/geometry.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class ArbitraryCurve:
    """
    Constructs an arbitrary curve.

    Args:
        curve:
            A curve in the form of a Python function
        x_range:
            The `(x_min, x_max, x_step)` values of the x-axis
        y_range:
            The `(y_min, y_max, y_step)` values of the y-axis
    """

    def __new__(
        cls,
        curve: Callable[[float], Any],
        *,
        x_range: Sequence[float] = (-5, 5, 1),
        y_range: Sequence[float] = (0, 5, 1),
        **kwargs: dict[str, Any],
    ) -> manim.ParametricFunction:
        axes = manim.Axes(x_range=x_range, y_range=y_range, **kwargs)
        plotted_curve = axes.plot(curve)

        def _new_repr(self):
            return f"ArbitraryCurve(curve={curve.__name__})"

        manim.ParametricFunction.__repr__ = _new_repr

        return plotted_curve

Circle ¤

Bases: Circle

Constructs a circular geometry with specified radius.

An alias class for manim.Circle.

Parameters:

Name Type Description Default
radius float

the radius of the circle

required
Source code in riemapp/geometry.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
class Circle(manim.Circle):
    """
    Constructs a circular geometry with specified radius.

    An alias class for manim.Circle.

    Args:
        radius:
            the radius of the circle
    """

    def __init__(self, radius: float, **kwargs: dict[str, Any]) -> None:
        self.radius = radius
        manim.Circle.__init__(self, self.radius, **kwargs)

    def __repr__(self) -> str:
        return f"Circle(radius={self.radius}) (alias for manim.Circle)"

Dot ¤

Bases: Dot

Constructs a circle with a very small radius.

An alias class for manim.Dot.

Source code in riemapp/geometry.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class Dot(manim.Dot):
    """
    Constructs a circle with a very small radius.

    An alias class for manim.Dot.

    """

    def __init__(
        self,
        point: list[float] | npt.NDArray[np.float64],
        radius: float,
        **kwargs: dict[str, Any],
    ) -> None:
        self.radius = radius
        self.point = point
        manim.Dot.__init__(self, point=self.point, radius=self.radius, **kwargs)

    def __repr__(self) -> str:
        return f"Dot(point={self.point}, radius={self.radius}) (alias for manim.Dot)"

Line ¤

Bases: Line

Constructs a Line geometry with the specified staring and end points.

An alias class for manim.Line.

Parameters:

Name Type Description Default
start Sequence[float] | NDArray[float64]

Line's starting points

required
end Sequence[float] | NDArray[float64]

Line's end points

required
Source code in riemapp/geometry.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
class Line(manim.Line):
    """
    Constructs a Line geometry with the specified staring and end points.

    An alias class for manim.Line.

    Args:
        start:
            Line's starting points
        end:
            Line's end points
    """

    def __init__(
        self,
        start: Sequence[float] | npt.NDArray[np.float64],
        end: Sequence[float] | npt.NDArray[np.float64],
        **kwargs: dict[str, Any],
    ):
        self.start = start
        self.end = end
        manim.Line.__init__(self, start=self.start, end=self.end, **kwargs)

    def __repr__(self) -> str:
        return f"Line(start={self.start}, end={self.end}) (alias for manim.Line)"

Polygon ¤

Bases: Polygon

Constructs a shape consisting of one close loop of vertices.

An alias class for manim.Polygon.

Parameters:

Name Type Description Default
*vertices Sequence[Sequence[float]]

Polygon's vertices points

()
Source code in riemapp/geometry.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class Polygon(manim.Polygon):
    """
    Constructs a shape consisting of one close loop of vertices.

    An alias class for manim.Polygon.

    Args:
        *vertices:
            Polygon's vertices points
    """

    def __init__(
        self, *vertices: Sequence[Sequence[float]], **kwargs: dict[str, Any]
    ) -> None:
        self.vertices = vertices
        manim.Polygon.__init__(self, *vertices, **kwargs)

    def __repr__(self) -> str:
        return (
            f"Polygon(vertices={[v for v in self.vertices]}) (alias for manim.Polygon)"
        )

RegularPolygon ¤

Bases: RegularPolygon

Constructs a n-sided regular Polygon.

An alias class for manim.RegularPolygon.

Parameters:

Name Type Description Default
n int

number of sides of the RegularPolygon

required
Source code in riemapp/geometry.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
class RegularPolygon(manim.RegularPolygon):
    """
    Constructs a n-sided regular Polygon.

    An alias class for manim.RegularPolygon.

    Args:
        n:
            number of sides of the RegularPolygon
    """

    def __init__(self, n: int, **kwargs: dict[str, Any]) -> None:
        self.n = n
        manim.RegularPolygon.__init__(self, self.n, **kwargs)

    def __repr__(self) -> str:
        return f"RegularPolygon(n={self.n}) (alias for manim.RegularPolygon)"

Square ¤

Bases: Square

Constructs a square geometry with the specified side length.

An alias class for manim.Square.

Parameters:

Name Type Description Default
side_length float

square's side length

required
Source code in riemapp/geometry.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Square(manim.Square):
    """
    Constructs a square geometry with the specified side length.

    An alias class for manim.Square.

    Args:
        side_length:
            square's side length
    """

    def __init__(self, side_length: float, **kwargs: dict[str, Any]) -> None:
        self.side_length = side_length
        manim.Square.__init__(self, self.side_length, **kwargs)

    def __repr__(self) -> str:
        return f"Square(side_length={self.side_length}) (alias for manim.Square)"

Triangle ¤

Bases: Triangle

Constructs an equilateral Triangle geometry.

An alias class for manim.Triangle.

Source code in riemapp/geometry.py
114
115
116
117
118
119
120
121
122
123
124
125
126
class Triangle(manim.Triangle):
    """
    Constructs an equilateral Triangle geometry.

    An alias class for manim.Triangle.

    """

    def __init__(self, **kwargs: dict[str, Any]) -> None:
        manim.Triangle.__init__(self, **kwargs)

    def __repr__(self) -> str:
        return "Triangle() (alias for manim.Triangle)"