A community maintained Python library for creating mathematical animations.
Examples
class ContinuousMotion(Scene):
def create(self):
func=lambda pos: np.sin(pos[0] / 2) UR + np.cos(pos[1] / 2) LEFT
stream_lines=StreamLines(func, stroke_width=2, max_anchors_per_line=30)
self.add(stream_lines)
stream_lines.start_animation(warm_up=False, flow_speed=1.5)
self.wait(stream_lines.virtual_time / stream_lines.flow_speed)
class OpeningManim(Scene):
def create(self):
title=Tex(r"That is just a few LaTeX")
basel=MathTex(r"sum_{n=1}^infty frac{1}{n^2}=frac{pi^2}{6}")
VGroup(title, basel).manage(DOWN)
self.play(
Write(title),
FadeIn(basel, shift=DOWN),
)
self.wait()
transform_title=Tex("That modified into once a remodel")
transform_title.to_corner(UP + LEFT)
self.play(
Remodel(title, transform_title),
LaggedStart(*(FadeOut(obj, shift=DOWN) for obj in basel)),
)
self.wait()
grid=NumberPlane()
grid_title=Tex("That is a grid", font_size=72)
grid_title.move_to(transform_title)
self.add(grid, grid_title) # Be obvious title is on top of grid
self.play(
FadeOut(title),
FadeIn(grid_title, shift=UP),
Make(grid, run_time=3, lag_ratio=0.1),
)
self.wait()
grid_transform_title=Tex(
r"That modified into once a non-linear characteristic \ applied to the grid",
)
grid_transform_title.move_to(grid_title, UL)
grid.prepare_for_nonlinear_transform()
self.play(
grid.animate.apply_function(
lambda p: p
+ np.array(
[
np.sin(p[1]),
np.sin(p[0]),
0,
],
),
),
run_time=3,
)
self.wait()
self.play(Remodel(grid_title, grid_transform_title))
self.wait()
class SquareToCircle(Scene):
def create(self):
circle=Circle()
sq.=Square()
sq..flip(RIGHT)
sq..rotate(-3 TAU / 8)
circle.set_fill(PINK, opacity=0.5)
self.play(Make(sq.))
self.play(Remodel(sq., circle))
self.play(FadeOut(sq.))
class UnionExample(Scene):
def create(self):
sq=Square(coloration=RED, fill_opacity=1).move_to([-2, 0, 0])
cr=Circle(coloration=BLUE, fill_opacity=1).move_to([-1.3, 0.7, 0])
un=Union(sq, cr, coloration=GREEN, fill_opacity=1).move_to([1.5, 0.3, 0])
self.add(sq, cr, un)
class WarpSquare(Scene):
def create(self):
sq.=Square()
self.play(
ApplyPointwiseFunction(
lambda level: complex_to_R3(np.exp(R3_to_complex(level))),
sq.,
),
)
self.wait()
Free and Commence Source
Manim is a free and birth-offer challenge in the origin written by Grant Sanderson. It is some distance now maintained by the Manim Neighborhood and permissively launched below the MIT license.