diff options
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves')
-rw-r--r-- | FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py | 100 |
1 files changed, 72 insertions, 28 deletions
diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py index 361e2be..7c970e5 100644 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py @@ -21,7 +21,7 @@ class arcl(MovingCameraScene): # lc1 = [Line(length = 0.05, color = RED).scale(0.2).rotate((-25 + i*2) * DEGREES).shift(np.array([-1 + 0.125*i, curve_(-1.5 + 0.1*i), 0])) for i in range(2)] # lc1b = VGroup(*lc1).shift(1.7*LEFT + 0.2*DOWN) - text = TextMobject(r'$r(t) = \left\langle t, t^{3} - 2t, 0\right\rangle$ \\ $r\prime (t) = \left\langle 1, 3t^{2} - 2, 0\right\rangle$').scale(0.7).shift(3*UP + 3*LEFT) + text = TextMobject(r'$r(t) = \left\langle t, t^{3} - 2t, 0\right\rangle$ \\ $r\prime (t) = \left\langle 1, 3t^{2} - 2, 0\right\rangle$').scale(0.7).shift(3*UP + 4*RIGHT) # l = VGroup(*lines, *lines2, lines2b, *lines4, *lines5, *lines6, lc1b).shift(curve.get_center()) l = VGroup(*lines, *lines2) @@ -33,47 +33,91 @@ class arcl(MovingCameraScene): dyt = DashedLine(dx.get_end(), dx.get_end() + np.array([0, 0.3 ,0])) dxtext = TextMobject(r'$dx$').scale(0.2).next_to(dx, RIGHT, buff = 0.01) dytext = TextMobject(r'$dy$').scale(0.2).next_to(dy, LEFT, buff = 0.01) - formula = TextMobject(r"Using Pythagoras' theorem, \\ $ds = \sqrt{(dx)^{2} + (dy)^{2}}$").scale(0.35).shift(5*LEFT + 0.2*UP) + formula = TextMobject(r"Consider a very small interval ", r'$ds$. \\', r"Using Pythagoras' theorem, \\", r'$ds$', r" = $\sqrt{(dx)^{2} + (dy)^{2}}$").scale(0.25).shift(5*LEFT + 0.5*UP) + formula.set_color_by_tex_to_color_map({ + "$ds$. \\": GREEN_SCREEN, + "$ds$": GREEN_SCREEN + }) - compute = TextMobject(r'To compute the arc length from \\ $t = -1.4$ to $t = -1.1$, \\ summation of all small arcs $ds$ \\ is given by $L = \int_{-1.4}^{-1.1} ds$ \\').scale(0.7).shift(6.8*LEFT + 1.5*UP) - compute_ = TextMobject(r'L = $ \int_{-1.4}^{-1.1} \sqrt{(\frac{dx}{dt})^{2} + (\frac{dy}{dt})^{2}}\quad dt$ \\ = $\int_{-1.4}^{-1.1} \sqrt{1^{2} + (3t^{2} - 2)^{2}}\quad dt$').scale(0.7).shift(6.8*LEFT + 0.6*DOWN) - compute = VGroup(*[compute, compute_]) - compute2 = TextMobject(r'$ = \int_{-1.4}^{-1.1} \sqrt{9t^{4} - 12t^{2} + 5}\quad dt$').scale(0.7).shift(6.8*LEFT + 1.7*DOWN) - compute3 = TextMobject(r'$L = 0.8693$').scale(0.7).shift(6.8*LEFT + 2.2*DOWN) + formula2 = TextMobject(r'To compute the arc length \\ from $a$ to $b$, we need to \\ sum over all intervals ', r'$ds$').scale(0.25).shift(5.2*LEFT + 0.7*UP) + formula2.set_color_by_tex_to_color_map({ + "$ds$": GREEN_SCREEN + }) - dsd = TextMobject(r'We can divide the curve \\ into multiple small arcs $ds$').scale(0.35).shift(5.2*LEFT + 0.2*UP) + formula3 = TextMobject(r'$L = \int_{a}^{b} ds$ \\ $= \int_{a}^{b} \sqrt{(\frac{dx}{dt})^{2} + (\frac{dy}{dt})^{2} + (\frac{dz}{dt})^{2}}\quad dt$').scale(0.25).shift(5.2*LEFT + 0.1*UP) - self.play(FadeIn(curve)) + bl = DashedLine(lines2[4].get_center(), lines2[4].get_center() + np.array([1,0,0])) + blt = TextMobject(r'$b$').scale(0.5).next_to(bl.get_center(), DOWN, buff=0.1) + al = DashedLine(lines[0].get_center(), lines[0].get_center() + np.array([1,0,0])) + alt = TextMobject(r'$a$').scale(0.5).next_to(al.get_center(), UP, buff=0.1) + pts = VGroup(*[bl, blt, al, alt]) + + compute = TextMobject(r'To compute the arc length from \\ $t = -1.4$ to $t = -1.1$, \\ summation of small intervals $ds$ \\ is given by $L = \int_{-1.4}^{-1.1} ds$ \\').scale(0.7).shift(6.8*LEFT + 2.5*UP) + compute_ = TextMobject(r'L = $ \int_{-1.4}^{-1.1} \sqrt{(\frac{dx}{dt})^{2} + (\frac{dy}{dt})^{2} + (\frac{dz}{dt})^{2}}\quad dt$ \\ = $\int_{-1.4}^{-1.1} \sqrt{1^{2} + (3t^{2} - 2)^{2} + 0^{2}}\quad dt$').scale(0.7).shift(6.8*LEFT + -0.6*DOWN) + #compute = VGroup(*[compute, compute_]) + compute2 = TextMobject(r'$ = \int_{-1.4}^{-1.1} \sqrt{9t^{4} - 12t^{2} + 5}\quad dt$').scale(0.7).shift(6.8*LEFT + 0.7*DOWN) + compute3 = TextMobject(r'$L = 0.8693$').scale(0.7).shift(6.8*LEFT + 1.2*DOWN) + arclen = compute3.copy() + arclen = arclen.scale(0.8).next_to(arc.get_center(), RIGHT, buff = 0.1) + dsd = TextMobject(r'We can divide the curve \\ into multiple small arcs ', r'$ds$').scale(0.25).shift(5.2*LEFT + 0.2*UP) + dsd.set_color_by_tex_to_color_map({ + "$ds$": GREEN_SCREEN + }) + + # 13th sec, consider a v small interval ds, show Pythagoras + # reduce text size + # then show we can divide curve into small ds + # all red ds + # To compute arc length, we need to sum over all intervals ds + # a and b show and give dashes dy dx for first and last + # give dz in formula and show it's zero + # Zooom out, Remove red bars, draw yellow line + # Consider t = -1.4 to -1.1 + # at end show l = 0.693 near yellow line, smaller size + + ax1 = Vector((0,1,0), color = YELLOW) + ax1l = TextMobject(r'$y$').next_to(ax1, LEFT, buff = 0) + ax2 = Vector((1,0,0), color = BLUE) + ax2l = TextMobject(r'$x$').next_to(ax2, RIGHT, buff = 0) + ax = VGroup(*[ax1, ax1l, ax2, ax2l]).scale(0.6).shift(3*DOWN + 6*LEFT) + + self.play(FadeIn(curve), FadeIn(ax)) self.play(ApplyMethod(curve.scale, 10), FadeIn(text)) # self.play(FadeIn(l)) self.wait(2) + self.play(FadeOut(text)) self.play(self.camera_frame.set_width, 5, self.camera_frame.move_to, 3.8*LEFT+0.4*DOWN, - text.shift, 2.3*LEFT + 2.25*DOWN, - text.scale, 0.5, run_time = 4) + ax.shift, UP, + ax.scale, 0.5, run_time = 4) long = ArcBetweenPoints(lines[1].get_center() + 0.01, lines2[3].get_center(), color = YELLOW, angle = 10*DEGREES).rotate(180*DEGREES) - # self.play(ApplyMethod(VGroup(*[curve, l]).scale,0.1, run_time = 4)) - # self.play(ApplyMethod(VGroup(*[curve, l]).scale,10, run_time = 4)) - # self.activate_zooming(animate = True) - self.play(Write(dsd), Write(l)) + + self.play(Write(formula),FadeIn(VGroup(*[arc, arctext, dy, dx, dxt, dyt, dxtext, dytext])), FadeIn(VGroup(*[lines[3], lines2[0]]))) self.wait(2) - self.play(FadeOut(dsd), Transform(l, VGroup(*[lines[3], lines2[0]])), FadeIn(VGroup(*[arc, arctext, dy, dx, dxt, dyt, dxtext, dytext]))) - self.wait(1) - self.play(FadeIn(formula)) - # self.play(FadeIn(VGroup(*[arc, dy, dx, dxt, dyt, dxtext, dytext]))) + self.play(ReplacementTransform(formula, dsd), TransformFromCopy(VGroup(*[lines[3], lines2[0]]) , l)) + #Transform(l, VGroup(*[lines[3], lines2[0]])), ) + self.wait(2) + self.play(ReplacementTransform(dsd, formula2), FadeIn(pts)) + self.wait(3) + self.play(FadeIn(formula3)) self.wait(2) - self.play(FadeOut(VGroup(*[arc, arctext, dy, l, dx, dxt, dyt, dxtext, dytext, formula]))) - self.play(self.camera_frame.set_width, 15, + self.play(FadeOut(VGroup(*[formula3, l, pts, formula2, arc, arctext, dy, dx, dxt, dyt, dxtext, dytext]))) + self.play( + self.camera_frame.set_width, 15, self.camera_frame.move_to, 3*LEFT, - text.shift, 2.5*LEFT + 2.25*UP, - text.scale, 2, run_time = 4) - self.play(FadeIn(long), FadeIn(compute)) - self.wait(4) + ax.shift, DOWN + 3*LEFT, + ax.scale, 2.3, + run_time = 4) + text = text.shift(2*LEFT) + self.play(FadeIn(long), FadeIn(compute), FadeIn(text)) + self.wait(2) + self.play(FadeIn(compute_)) + self.wait(2) self.play(FadeIn(compute2)) self.wait(1) self.play(FadeIn(compute3)) - # self.play(FadeOut(VGroup(*[curve, arc, dy, dx, dxt, dyt, dxtext, dytext, l]))) - # self.play(FadeOut(self.zoomed_camera.frame), FadeOut(self.zoomed_display)) self.wait(1) - self.play(FadeOut(VGroup(*[curve, text, compute, compute2, compute3, long]))) + self.play(TransformFromCopy(compute3, arclen)) + self.wait(2) + self.play(FadeOut(VGroup(*[ax, arclen, compute_, curve, text, compute, compute2, compute3, long]))) |