def construct(self): glass = self.get_continuous_glass() self.play(ApplyMethod(glass.fade, 0.8)) self.freeze_background() paths = self.get_paths() for path in paths: if path.get_height() > self.total_glass_height: path.stretch(0.7, 1) path.shift(self.top - path.get_top()) path.rgbas[:, 2] = 0 loop = paths.pop(1) ##Bad! randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) photon_run = self.photon_run_along_path( loop, rate_func=lambda t: smooth(1.2 * t, 2), run_time=4.1) text = self.get_text().to_edge(UP, buff=0.2) self.play(ShowCreation(loop)) self.dither() self.play(photon_run) self.remove(photon_run.mobject) randy = self.slide(randy, loop) self.add(randy) self.dither() self.remove(randy) self.play(ShimmerIn(text)) for path in paths: self.play( Transform(loop, path, path_func=path_along_arc(np.pi / 2), run_time=2))
def construct(self): self.knob = Circle(color = BLUE_D) self.knob.add_line(UP, DOWN) self.knob.to_corner(UP+RIGHT) self.knob.shift(0.5*DOWN) self.last_angle = np.pi/2 arrow = Vector(ORIGIN, RIGHT) arrow.next_to(self.knob, LEFT) words = TextMobject("Turn this knob over time to define the curve") words.next_to(arrow, LEFT) self.path = self.get_path() self.path.shift(1.5*DOWN) self.path.show() self.path.highlight(BLACK) randy = Randolph() randy.scale(RANDY_SCALE_VAL) randy.shift(-randy.get_bottom()) self.play(ShimmerIn(words)) self.play(ShowCreation(arrow)) self.play(ShowCreation(self.knob)) self.dither() self.add(self.path) self.slide(randy, self.path) self.dither()
def construct(self): self.knob = Circle(color=BLUE_D) self.knob.add_line(UP, DOWN) self.knob.to_corner(UP + RIGHT) self.knob.shift(0.5 * DOWN) self.last_angle = np.pi / 2 arrow = Vector(ORIGIN, RIGHT) arrow.next_to(self.knob, LEFT) words = TextMobject("Turn this knob over time to define the curve") words.next_to(arrow, LEFT) self.path = self.get_path() self.path.shift(1.5 * DOWN) self.path.show() self.path.highlight(BLACK) randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) self.play(ShimmerIn(words)) self.play(ShowCreation(arrow)) self.play(ShowCreation(self.knob)) self.dither() self.add(self.path) self.slide(randy, self.path) self.dither()
def construct(self): self.add_cycloid_end_points() start = self.point_a.get_center() end = self.point_b.get_center() angle = 2 * np.pi / 3 path = Arc(angle, radius=3) path.gradient_highlight(RED_D, WHITE) radius = Line(ORIGIN, path.points[0]) randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) randy_copy = randy.copy() words = TextMobject( "Circular paths are good, \\\\ but still not the best") words.shift(UP) self.play( ShowCreation(path), ApplyMethod(radius.rotate, angle, path_func=path_along_arc(angle))) self.play(FadeOut(radius)) self.play(ApplyMethod(path.position_endpoints_on, start, end, path_func=path_along_arc(-angle)), run_time=3) self.adjust_mobject_to_index(randy_copy, 1, path.points) self.play(FadeIn(randy_copy)) self.remove(randy_copy) self.slide(randy, path) self.play(ShimmerIn(words)) self.dither()
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() self.add(self.cycloid) self.slide(randy, self.cycloid) self.play(self.photon_run_along_path(self.cycloid)) self.wait()
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() self.add(self.cycloid) self.slide(randy, self.cycloid) self.play(self.photon_run_along_path(self.cycloid)) self.dither()
def construct(self, with_words): CycloidScene.construct(self) randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) central_randy = randy.copy() start_randy = self.adjust_mobject_to_index( randy.copy(), 1, self.cycloid.points ) if with_words: words1 = TextMobject("Trajectory due to gravity") arrow = TexMobject("\\leftrightarrow") words2 = TextMobject("Trajectory due \\emph{constantly} rotating wheel") words1.next_to(arrow, LEFT) words2.next_to(arrow, RIGHT) words = Mobject(words1, arrow, words2) words.scale_to_fit_width(2*SPACE_WIDTH-1) words.to_edge(UP, buff = 0.2) words.to_edge(LEFT) self.play(ShowCreation(self.cycloid.copy())) self.slide(randy, self.cycloid) self.add(self.slider) self.wait() self.grow_parts() self.draw_cycloid() self.wait() self.play(Transform(self.slider, start_randy)) self.wait() self.roll_back() self.wait() if with_words: self.play(*map(ShimmerIn, [words1, arrow, words2])) self.wait() self.remove(self.circle) start_time = len(self.frames)*self.frame_duration self.remove(self.slider) self.slide(central_randy, self.cycloid) end_time = len(self.frames)*self.frame_duration self.play_over_time_range( start_time, end_time, RollAlongVector( self.circle, self.cycloid.points[-1]-self.cycloid.points[0], run_time = end_time-start_time, rate_func = None ) ) self.add(self.circle, self.slider) self.wait()
def construct(self, with_words): CycloidScene.construct(self) randy = Randolph() randy.scale(RANDY_SCALE_VAL) randy.shift(-randy.get_bottom()) central_randy = randy.copy() start_randy = self.adjust_mobject_to_index( randy.copy(), 1, self.cycloid.points ) if with_words: words1 = TextMobject("Trajectory due to gravity") arrow = TexMobject("\\leftrightarrow") words2 = TextMobject("Trajectory due \\emph{constantly} rotating wheel") words1.next_to(arrow, LEFT) words2.next_to(arrow, RIGHT) words = Mobject(words1, arrow, words2) words.scale_to_fit_width(2*SPACE_WIDTH-1) words.to_edge(UP, buff = 0.2) words.to_edge(LEFT) self.play(ShowCreation(self.cycloid.copy())) self.slide(randy, self.cycloid) self.add(self.slider) self.dither() self.grow_parts() self.draw_cycloid() self.dither() self.play(Transform(self.slider, start_randy)) self.dither() self.roll_back() self.dither() if with_words: self.play(*map(ShimmerIn, [words1, arrow, words2])) self.dither() self.remove(self.circle) start_time = len(self.frames)*self.frame_duration self.remove(self.slider) self.slide(central_randy, self.cycloid) end_time = len(self.frames)*self.frame_duration self.play_over_time_range( start_time, end_time, RollAlongVector( self.circle, self.cycloid.points[-1]-self.cycloid.points[0], run_time = end_time-start_time, rate_func = None ) ) self.add(self.circle, self.slider) self.dither()
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() arrow = Arrow(ORIGIN, 2 * RIGHT) arrows = Mobject( * [arrow.copy().shift(vect) for vect in 3 * LEFT, ORIGIN, 3 * RIGHT]) arrows.shift(2 * SPACE_WIDTH * RIGHT) self.add(arrows) self.add(self.cycloid) self.slide(randy, self.cycloid) everything = Mobject(*self.mobjects) self.play( ApplyMethod(everything.shift, 4 * SPACE_WIDTH * LEFT, run_time=2, rate_func=rush_into))
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_VAL) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() arrow = Arrow(ORIGIN, 2*RIGHT) arrows = Mobject(*[ arrow.copy().shift(vect) for vect in 3*LEFT, ORIGIN, 3*RIGHT ]) arrows.shift(2*SPACE_WIDTH*RIGHT) self.add(arrows) self.add(self.cycloid) self.slide(randy, self.cycloid) everything = Mobject(*self.mobjects) self.play(ApplyMethod( everything.shift, 4*SPACE_WIDTH*LEFT, run_time = 2, rate_func = rush_into ))
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_VAL) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() points = self.cycloid.points ceiling = points[0, 1] n = len(points) broken_points = [ points[k*n/self.num_pieces:(k+1)*n/self.num_pieces] for k in range(self.num_pieces) ] words = TextMobject(""" What determines the speed\\\\ at each point? """) words.to_edge(UP) self.add(self.cycloid) sliders, vectors = [], [] for points in broken_points: path = Mobject().add_points(points) vect = points[-1] - points[-2] magnitude = np.sqrt(ceiling - points[-1, 1]) vect = magnitude*vect/np.linalg.norm(vect) slider = self.slide(randy, path, ceiling = ceiling) vector = Vector(slider.get_center(), vect) self.add(slider, vector) sliders.append(slider) vectors.append(vector) self.dither() self.play(ShimmerIn(words)) self.dither(3) slider = sliders.pop(1) vector = vectors.pop(1) faders = sliders+vectors+[words] self.play(*map(FadeOut, faders)) self.remove(*faders) self.show_geometry(slider, vector)
def construct(self): randy = Randolph() randy.shift(-randy.get_bottom()) self.slider = randy.copy() randy.scale(RANDY_SCALE_VAL) paths = self.get_paths() point_a = Dot(paths[0].points[0]) point_b = Dot(paths[0].points[-1]) A = TexMobject("A").next_to(point_a, LEFT) B = TexMobject("B").next_to(point_b, RIGHT) for point, tex in [(point_a, A), (point_b, B)]: self.play(ShowCreation(point)) self.play(ShimmerIn(tex)) self.dither() curr_path = None for path in paths: new_slider = self.adjust_mobject_to_index( randy.copy(), 1, path.points ) if curr_path is None: curr_path = path self.play(ShowCreation(curr_path)) else: self.play(Transform(curr_path, path)) self.play(Transform(self.slider, new_slider)) self.dither() self.remove(self.slider) self.slide(randy, curr_path) self.clear() self.add(point_a, point_b, A, B, curr_path) text = self.get_text() text.to_edge(UP) self.play(ShimmerIn(text)) for path in paths: self.play(Transform( curr_path, path, path_func = path_along_arc(np.pi/2), run_time = 3 ))
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() points = self.cycloid.points ceiling = points[0, 1] n = len(points) broken_points = [ points[k * n / self.num_pieces:(k + 1) * n / self.num_pieces] for k in range(self.num_pieces) ] words = TextMobject(""" What determines the speed\\\\ at each point? """) words.to_edge(UP) self.add(self.cycloid) sliders, vectors = [], [] for points in broken_points: path = Mobject().add_points(points) vect = points[-1] - points[-2] magnitude = np.sqrt(ceiling - points[-1, 1]) vect = magnitude * vect / np.linalg.norm(vect) slider = self.slide(randy, path, ceiling=ceiling) vector = Vector(slider.get_center(), vect) self.add(slider, vector) sliders.append(slider) vectors.append(vector) self.dither() self.play(ShimmerIn(words)) self.dither(3) slider = sliders.pop(1) vector = vectors.pop(1) faders = sliders + vectors + [words] self.play(*map(FadeOut, faders)) self.remove(*faders) self.show_geometry(slider, vector)
def construct(self): randy = Randolph() randy.shift(-randy.get_bottom()) self.slider = randy.copy() randy.scale(RANDY_SCALE_FACTOR) paths = self.get_paths() point_a = Dot(paths[0].points[0]) point_b = Dot(paths[0].points[-1]) A = TexMobject("A").next_to(point_a, LEFT) B = TexMobject("B").next_to(point_b, RIGHT) for point, tex in [(point_a, A), (point_b, B)]: self.play(ShowCreation(point)) self.play(ShimmerIn(tex)) self.wait() curr_path = None for path in paths: new_slider = self.adjust_mobject_to_index( randy.copy(), 1, path.points ) if curr_path is None: curr_path = path self.play(ShowCreation(curr_path)) else: self.play(Transform(curr_path, path)) self.play(Transform(self.slider, new_slider)) self.wait() self.remove(self.slider) self.slide(randy, curr_path) self.clear() self.add(point_a, point_b, A, B, curr_path) text = self.get_text() text.to_edge(UP) self.play(ShimmerIn(text)) for path in paths: self.play(Transform( curr_path, path, path_func = path_along_arc(np.pi/2), run_time = 3 ))
def construct(self): self.add_cycloid_end_points() start = self.point_a.get_center() end = self.point_b.get_center() angle = 2*np.pi/3 path = Arc(angle, radius = 3) path.gradient_highlight(RED_D, WHITE) radius = Line(ORIGIN, path.points[0]) randy = Randolph() randy.scale(RANDY_SCALE_VAL) randy.shift(-randy.get_bottom()) randy_copy = randy.copy() words = TextMobject("Circular paths are good, \\\\ but still not the best") words.shift(UP) self.play( ShowCreation(path), ApplyMethod( radius.rotate, angle, path_func = path_along_arc(angle) ) ) self.play(FadeOut(radius)) self.play( ApplyMethod( path.position_endpoints_on, start, end, path_func = path_along_arc(-angle) ), run_time = 3 ) self.adjust_mobject_to_index(randy_copy, 1, path.points) self.play(FadeIn(randy_copy)) self.remove(randy_copy) self.slide(randy, path) self.play(ShimmerIn(words)) self.dither()
def construct(self): glass = self.get_continuous_glass() self.play(ApplyMethod(glass.fade, 0.8)) self.freeze_background() paths = self.get_paths() for path in paths: if path.get_height() > self.total_glass_height: path.stretch(0.7, 1) path.shift(self.top - path.get_top()) path.rgbs[:,2] = 0 loop = paths.pop(1) ##Bad! randy = Randolph() randy.scale(RANDY_SCALE_VAL) randy.shift(-randy.get_bottom()) photon_run = self.photon_run_along_path( loop, rate_func = lambda t : smooth(1.2*t, 2), run_time = 4.1 ) text = self.get_text().to_edge(UP, buff = 0.2) self.play(ShowCreation(loop)) self.dither() self.play(photon_run) self.remove(photon_run.mobject) randy = self.slide(randy, loop) self.add(randy) self.dither() self.remove(randy) self.play(ShimmerIn(text)) for path in paths: self.play(Transform( loop, path, path_func = path_along_arc(np.pi/2), run_time = 2 ))
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_VAL) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() self.slide(randy, self.cycloid, roll = True)
def construct(self): randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) randy.shift(-randy.get_bottom()) self.add_cycloid_end_points() self.slide(randy, self.cycloid, roll=True)