Skip to content

Commit def7241

Browse files
Add Homotopy example for waving square (#4100)
* Add missing changes for homotopy example * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f18a2b4 commit def7241

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

manim/animation/movement.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ class Homotopy(Animation):
4444
Keyword arguments propagated to :meth:`.Mobject.apply_function`.
4545
kwargs
4646
Further keyword arguments passed to the parent class.
47+
48+
Examples
49+
--------
50+
51+
.. manim:: HomotopyExample
52+
53+
class HomotopyExample(Scene):
54+
def construct(self):
55+
square = Square()
56+
57+
def homotopy(x, y, z, t):
58+
if t <= 0.25:
59+
progress = t / 0.25
60+
return (x, y + progress * 0.2 * np.sin(x), z)
61+
else:
62+
wave_progress = (t - 0.25) / 0.75
63+
return (x, y + 0.2 * np.sin(x + 10 * wave_progress), z)
64+
65+
self.play(Homotopy(homotopy, square, rate_func= linear, run_time=2))
66+
4767
"""
4868

4969
def __init__(

0 commit comments

Comments
 (0)