Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Merge branch 'lighthouse-grant' into lighthouse2

Grant Sanderson3944c8a2d8f6
diff --cc active_projects/basel.py
index 8a069ddf5,6af405deb..20814be54
--- a/active_projects/basel.py
+++ b/active_projects/basel.py
@@@ -929,15 -907,15 +927,11 @@@ class SingleLighthouseScene(PiCreatureS
class MorphIntoSunScene(PiCreatureScene):
--
def construct(self):
--
self.setup_elements()
self.morph_lighthouse_into_sun()
--
def setup_elements(self):
--
self.remove(self.get_primary_pi_creature())
SCREEN_SIZE = 3.0
@@@ -988,10 -966,10 +982,8 @@@
self.add_foreground_mobject(self.light_source.shadow)
self.add_foreground_mobject(morty)
--
self.light_source.dim_ambient
self.add(self.light_source.spotlight)
--
self.screen_tracker = ScreenTracker(self.light_source)
self.add(self.screen_tracker)
@@@ -4351,208 -3273,4 +4343,194 @@@ class ArcHighlightOverlayScene(Scene)
)
-- flash_arcs(3)
-
-
-
+
+class ThumbnailScene(Scene):
+
+ def construct(self):
+
+ equation = TexMobject("1+{1\over 4}+{1\over 9}+{1\over 16}+{1\over 25}+\dots")
+ equation.scale(1.5)
+ equation.move_to(1.5 * UP)
+ q_mark = TexMobject("=?", color = LIGHT_COLOR).scale(5)
+ q_mark.next_to(equation, DOWN, buff = 1.5)
+ #equation.move_to(2 * UP)
+ #q_mark = TexMobject("={\pi^2\over 6}", color = LIGHT_COLOR).scale(3)
+ #q_mark.next_to(equation, DOWN, buff = 1)
+
+ lake_radius = 6
+ lake_center = ORIGIN
+ op_scale = 0.4
+
+ lake = Circle(
+ fill_color = LAKE_COLOR,
+ fill_opacity = LAKE_OPACITY,
+ radius = lake_radius,
+ stroke_color = LAKE_STROKE_COLOR,
+ stroke_width = LAKE_STROKE_WIDTH,
+ )
+ lake.move_to(lake_center)
+
+ for i in range(16):
+ theta = -TAU/4 + (i + 0.5) * TAU/16
+ pos = lake_center + lake_radius * np.array([np.cos(theta), np.sin(theta), 0])
+ ls = LightSource(
+ radius = 15.0,
+ num_levels = 150,
+ max_opacity_ambient = 1.0,
+ opacity_function = inverse_quadratic(1,op_scale,1)
+ )
+ ls.move_source_to(pos)
+ lake.add(ls.ambient_light, ls.lighthouse)
+
+ self.add(lake)
+
+ self.add(equation, q_mark)
+
+ self.wait()
+
+
+
+
+class InfiniteCircleScene(PiCreatureScene):
+
+ def construct(self):
+
+ morty = self.get_primary_pi_creature()
+ morty.highlight(MAROON_D).flip()
+ morty.color = MAROON_D
+ morty.scale(0.5).move_to(ORIGIN)
+
+ arrow = Arrow(ORIGIN, 2.4 * RIGHT)
+ dot = Dot(color = BLUE).next_to(arrow)
+ ellipsis = TexMobject("\dots")
+
+ infsum = VGroup()
+ infsum.add(ellipsis.copy())
+
+ for i in range(3):
+ infsum.add(arrow.copy().next_to(infsum.submobjects[-1]))
+ infsum.add(dot.copy().next_to(infsum.submobjects[-1]))
+
+ infsum.add(arrow.copy().next_to(infsum.submobjects[-1]))
+ infsum.add(ellipsis.copy().next_to(infsum.submobjects[-1]))
+
+ infsum.next_to(morty,DOWN, buff = 1)
+
+ self.wait()
+ self.play(
+ LaggedStart(FadeIn,infsum,lag_ratio = 0.2)
+ )
+ self.wait()
+
+ A = infsum.submobjects[-1].get_center() + 0.5 * RIGHT
+ B = A + RIGHT + 1.3 * UP + 0.025 * LEFT
+ right_arc = DashedLine(TAU/4*UP, ORIGIN, stroke_color = YELLOW,
+ stroke_width = 8).apply_complex_function(np.exp)
+ right_arc.rotate(-TAU/4).next_to(infsum, RIGHT).shift(0.5 * UP)
+ right_tip_line = Arrow(B - UP, B, color = WHITE)
+ right_tip_line.add_tip()
+ right_tip = right_tip_line.get_tip()
+ right_tip.set_fill(color = YELLOW)
+ right_arc.add(right_tip)
+
+
+ C = B + 3.2 * UP
+ right_line = DashedLine(B + 0.2 * DOWN,C + 0.2 * UP, stroke_color = YELLOW,
+ stroke_width = 8)
+
+ ru_arc = right_arc.copy().rotate(angle = TAU/4)
+ ru_arc.remove(ru_arc.submobjects[-1])
+ ru_arc.to_edge(UP+RIGHT, buff = 0.15)
+
+ D = np.array([5.85, 3.85,0])
+ E = np.array([-D[0],D[1],0])
+ up_line = DashedLine(D, E, stroke_color = YELLOW,
+ stroke_width = 8)
+
+ lu_arc = ru_arc.copy().flip().to_edge(LEFT + UP, buff = 0.15)
+ left_line = right_line.copy().flip(axis = RIGHT).to_edge(LEFT, buff = 0.15)
+
+ left_arc = right_arc.copy().rotate(-TAU/4)
+ left_arc.next_to(infsum, LEFT).shift(0.5 * UP + 0.1 * LEFT)
+
+ right_arc.shift(0.2 * RIGHT)
+ right_line.shift(0.2 * RIGHT)
+
+ self.play(FadeIn(right_arc))
+ self.play(ShowCreation(right_line))
+ self.play(FadeIn(ru_arc))
+ self.play(ShowCreation(up_line))
+ self.play(FadeIn(lu_arc))
+ self.play(ShowCreation(left_line))
+ self.play(FadeIn(left_arc))
+
+
+
+ self.wait()
+
+
+
+
+class RightAnglesOverlay(Scene):
+
+ def construct(self):
+
+ BASELINE_YPOS = -2.5
+ OBSERVER_POINT = [0,BASELINE_YPOS,0]
+ LAKE0_RADIUS = 1.5 * 2
+ INDICATOR_RADIUS = 0.6
+ TICK_SIZE = 0.5
+ LIGHTHOUSE_HEIGHT = 0.2
+ LAKE_COLOR = BLUE
+ LAKE_OPACITY = 0.15
+ LAKE_STROKE_WIDTH = 5.0
+ LAKE_STROKE_COLOR = BLUE
+ TEX_SCALE = 0.8
+ DOT_COLOR = BLUE
+
+ RIGHT_ANGLE_SIZE = 0.3
+
+
+ def right_angle(pointA, pointB, pointC, size = 1):
+
+ v1 = pointA - pointB
+ v1 = size * v1/np.linalg.norm(v1)
+ v2 = pointC - pointB
+ v2 = size * v2/np.linalg.norm(v2)
+
+ P = pointB
+ Q = pointB + v1
+ R = Q + v2
+ S = R - v1
+ angle_sign = VMobject()
+ angle_sign.set_points_as_corners([P,Q,R,S,P])
+ angle_sign.mark_paths_closed = True
+ angle_sign.set_fill(color = WHITE, opacity = 1)
+ angle_sign.set_stroke(width = 0)
+ return angle_sign
+
+
+ lake_center = OBSERVER_POINT + LAKE0_RADIUS * UP
+ points = []
+ lines = VGroup()
+ for i in range(4):
+ theta = -TAU/4 + (i+0.5)*TAU/4
+ v = np.array([np.cos(theta), np.sin(theta), 0])
+ P = lake_center + LAKE0_RADIUS * v
+ points.append(P)
+ lines.add(Line(lake_center, P, stroke_width = 8))
+
+ self.play(FadeIn(lines))
+
+ self.wait()
+
+ for i in range(4):
+ sign = right_angle(points[i-1], lake_center, points[i],RIGHT_ANGLE_SIZE)
+ self.play(FadeIn(sign))
+ self.play(FadeOut(sign))
+
+ self.wait()
+
+ self.play(FadeOut(lines))
+
-
-
-
-
-
-
-
-
-
-
-
++ flash_arcs(3)