Answer to the question by IFNAV on reddit if a certain animation was possible in Manim https://www.reddit.com/r/manim/comments/1mxjr77/is_it_possible_with_manim/
Last active
August 23, 2025 11:35
-
-
Save uwezi/4c870580f5331645c811973c08740c07 to your computer and use it in GitHub Desktop.
[La Linea] Animation of a diamond breaking a sine wave. #manim #union #boolean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from manim import * | |
class possible2(Scene): | |
def construct(self): | |
phase = ValueTracker(0) | |
def bottom(): | |
return VMobject().add_points_as_corners( | |
[ | |
*[[x,0.5*np.sin(x-phase.get_value()),0] for x in np.linspace(-8,8,1000)], | |
[8,-8,0],[-8,-8,0],[-8,0,0] | |
] | |
).reverse_direction() | |
object = Square().rotate(45*DEGREES).move_to([0,-3,0]) | |
wave = always_redraw(lambda: | |
Union( | |
bottom(), | |
object.move_to([0,-3+0.5*phase.get_value(),0]) | |
).set_stroke(width=3,color=WHITE).set_fill(opacity=0) | |
) | |
self.add(wave) | |
self.play( | |
phase.animate.set_value(4*PI), run_time=4, rate_func=rate_functions.linear | |
) | |
self.wait() | |
class possible3(Scene): | |
def construct(self): | |
phase = ValueTracker(0) | |
def bottom(): | |
return VMobject().add_points_as_corners( | |
[ | |
*[[x,0.5*np.sin(x-phase.get_value()),0] for x in np.linspace(-8,8,1000)], | |
[8,-8,0],[-8,-8,0],[-8,0,0] | |
] | |
).reverse_direction() | |
object = Square(stroke_width=0,fill_opacity=0).set_z_index(-10).rotate(45*DEGREES).move_to([0,-3,0]) | |
self.add(object) | |
wave = always_redraw(lambda: | |
Union( | |
bottom(), | |
object | |
).set_stroke(width=3,color=WHITE).set_fill(opacity=0) | |
) | |
self.add(wave) | |
path = Arc(radius=4,start_angle=0,angle=PI) | |
self.play( | |
MoveAlongPath(object,path), | |
phase.animate.set_value(4*PI), run_time=4, rate_func=rate_functions.linear | |
) | |
self.wait() | |
class possible4(Scene): | |
def construct(self): | |
phase = ValueTracker(0) | |
def bottom(): | |
return VMobject().add_points_as_corners( | |
[ | |
*[[x,0.5*np.sin(x-phase.get_value()),0] for x in np.linspace(-8,8,1000)], | |
[8,-8,0],[-8,-8,0],[-8,0,0] | |
] | |
).reverse_direction() | |
object = Square(stroke_width=0,fill_opacity=0).set_z_index(-10).rotate(45*DEGREES).move_to([0,-3,0]) | |
self.add(object) | |
wave = always_redraw(lambda: | |
Union( | |
bottom(), | |
object | |
).set_stroke(width=3,color=WHITE).set_fill(opacity=0) | |
) | |
self.add(wave) | |
path = FunctionGraph( | |
lambda x: 3-0.5*x**2, | |
x_range=[-4,4,0.1] | |
).reverse_direction() | |
self.play( | |
MoveAlongPath(object,path), | |
phase.animate.set_value(4*PI), run_time=4, rate_func=rate_functions.linear | |
) | |
self.wait() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment