def get_paths(self): sharp_corner = Mobject( Line(3*UP+LEFT, LEFT), Arc(angle = np.pi/2, start_angle = np.pi), Line(DOWN, DOWN+3*RIGHT) ).ingest_submobjects().highlight(GREEN) paths = [ Arc( angle = np.pi/2, radius = 3, start_angle = 4 ), LoopTheLoop(), Line(7*LEFT, 7*RIGHT, color = RED_D), sharp_corner, FunctionGraph( lambda x : 0.05*(x**2)+0.1*np.sin(2*x) ), FunctionGraph( lambda x : x**2, x_min = -3, x_max = 2, density = 3*DEFAULT_POINT_DENSITY_1D ) ] cycloid = Cycloid() self.align_paths(paths, cycloid) return paths + [cycloid]
def get_path(self): result = FunctionGraph(lambda x: 0.05 * (x**2) + 0.1 * np.sin(2 * x)) result.rotate(-np.pi / 20) result.scale(0.7) result.shift(DOWN) return result
def get_path(self): result = FunctionGraph( lambda x : 0.05*(x**2)+0.1*np.sin(2*x) ) result.rotate(-np.pi/20) result.scale(0.7) result.shift(DOWN) return result
def construct(self): horiz_radius = 5 vert_radius = 3 vert_axis = NumberLine(numerical_radius=vert_radius) vert_axis.rotate(np.pi / 2) vert_axis.shift(horiz_radius * LEFT) horiz_axis = NumberLine(numerical_radius=5, numbers_with_elongated_ticks=[]) axes = Mobject(horiz_axis, vert_axis) graph = FunctionGraph(lambda x: 0.4 * (x - 2) * (x + 2) + 3, x_min=-2, x_max=2, density=3 * DEFAULT_POINT_DENSITY_1D) graph.stretch_to_fit_width(2 * horiz_radius) graph.highlight(YELLOW) min_point = Dot(graph.get_bottom()) nature_finds = TextMobject("Nature finds this point") nature_finds.scale(0.5) nature_finds.highlight(GREEN) nature_finds.shift(2 * RIGHT + 3 * UP) arrow = Arrow(nature_finds.get_bottom(), min_point, color=GREEN) side_words_start = TextMobject("Parameter describing") top_words, last_side_words = [ map(TextMobject, pair) for pair in [("Light's travel time", "Potential energy"), ("path", "mechanical state")] ] for word in top_words + last_side_words + [side_words_start]: word.scale(0.7) side_words_start.next_to(horiz_axis, DOWN) side_words_start.to_edge(RIGHT) for words in top_words: words.next_to(vert_axis, UP) words.to_edge(LEFT) for words in last_side_words: words.next_to(side_words_start, DOWN) for words in top_words[1], last_side_words[1]: words.highlight(RED) self.add(axes, top_words[0], side_words_start, last_side_words[0]) self.play(ShowCreation(graph)) self.play(ShimmerIn(nature_finds), ShowCreation(arrow), ShowCreation(min_point)) self.dither() self.play(FadeOut(top_words[0]), FadeOut(last_side_words[0]), GrowFromCenter(top_words[1]), GrowFromCenter(last_side_words[1])) self.dither(3)
def construct(self): horiz_radius = 5 vert_radius = 3 vert_axis = NumberLine(numerical_radius = vert_radius) vert_axis.rotate(np.pi/2) vert_axis.shift(horiz_radius*LEFT) horiz_axis = NumberLine( numerical_radius = 5, numbers_with_elongated_ticks = [] ) axes = Mobject(horiz_axis, vert_axis) graph = FunctionGraph( lambda x : 0.4*(x-2)*(x+2)+3, x_min = -2, x_max = 2, density = 3*DEFAULT_POINT_DENSITY_1D ) graph.stretch_to_fit_width(2*horiz_radius) graph.highlight(YELLOW) min_point = Dot(graph.get_bottom()) nature_finds = TextMobject("Nature finds this point") nature_finds.scale(0.5) nature_finds.highlight(GREEN) nature_finds.shift(2*RIGHT+3*UP) arrow = Arrow( nature_finds.get_bottom(), min_point, color = GREEN ) side_words_start = TextMobject("Parameter describing") top_words, last_side_words = [ map(TextMobject, pair) for pair in [ ("Light's travel time", "Potential energy"), ("path", "mechanical state") ] ] for word in top_words + last_side_words + [side_words_start]: word.scale(0.7) side_words_start.next_to(horiz_axis, DOWN) side_words_start.to_edge(RIGHT) for words in top_words: words.next_to(vert_axis, UP) words.to_edge(LEFT) for words in last_side_words: words.next_to(side_words_start, DOWN) for words in top_words[1], last_side_words[1]: words.highlight(RED) self.add( axes, top_words[0], side_words_start, last_side_words[0] ) self.play(ShowCreation(graph)) self.play( ShimmerIn(nature_finds), ShowCreation(arrow), ShowCreation(min_point) ) self.dither() self.play( FadeOut(top_words[0]), FadeOut(last_side_words[0]), GrowFromCenter(top_words[1]), GrowFromCenter(last_side_words[1]) ) self.dither(3)