Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add Homotopy example for waving square (#4100)

Irvanal Haqdef7241db33a
diff --git a/manim/animation/movement.py b/manim/animation/movement.py
index 0be7e01c1..b9b185db0 100644
--- a/manim/animation/movement.py
+++ b/manim/animation/movement.py
@@ -44,6 +44,26 @@ class Homotopy(Animation):
Keyword arguments propagated to :meth:`.Mobject.apply_function`.
kwargs
Further keyword arguments passed to the parent class.
+
+ Examples
+ --------
+
+ .. manim:: HomotopyExample
+
+ class HomotopyExample(Scene):
+ def construct(self):
+ square = Square()
+
+ def homotopy(x, y, z, t):
+ if t <= 0.25:
+ progress = t / 0.25
+ return (x, y + progress * 0.2 * np.sin(x), z)
+ else:
+ wave_progress = (t - 0.25) / 0.75
+ return (x, y + 0.2 * np.sin(x + 10 * wave_progress), z)
+
+ self.play(Homotopy(homotopy, square, rate_func= linear, run_time=2))
+
"""
def __init__(