Homotopy¶
Qualified name: manim.animation.movement.Homotopy
- class Homotopy(mobject=None, *args, use_override=True, **kwargs)[source]¶
Bases:
AnimationA Homotopy.
This is an animation transforming the points of a mobject according to the specified transformation function. With the parameter \(t\) moving from 0 to 1 throughout the animation and \((x, y, z)\) describing the coordinates of the point of a mobject, the function passed to the
homotopykeyword argument should transform the tuple \((x, y, z, t)\) to \((x', y', z')\), the coordinates the original point is transformed to at time \(t\).- Parameters:
homotopy (Callable[[float, float, float, float], tuple[float, float, float]]) – A function mapping \((x, y, z, t)\) to \((x', y', z')\).
mobject (Mobject) – The mobject transformed under the given homotopy.
run_time (float) – The run time of the animation.
apply_function_kwargs (dict[str, Any] | None) – Keyword arguments propagated to
Mobject.apply_function().kwargs (Any) – Further keyword arguments passed to the parent class.
Examples
Example: HomotopyExample ¶
from manim import * 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))
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))Methods
function_at_time_tinterpolate_submobjectAttributes
run_time- _original__init__(homotopy, mobject, run_time=3, apply_function_kwargs=None, **kwargs)¶
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
homotopy (Callable[[float, float, float, float], tuple[float, float, float]])
mobject (Mobject)
run_time (float)
apply_function_kwargs (dict[str, Any] | None)
kwargs (Any)