From c6b8ce1e059020bb130522afe9847e6d304b8177 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Tue, 7 Jul 2020 14:49:33 +0530 Subject: arcl, velocity changes --- .../arc-length-and-curvature/file1_arc_length.py | 89 ++++++++++++++++----- .../file4_curvature_interpretation.py | 16 ++-- .../file2_non_differentiable.py | 36 +++++++++ .../file2_tangent_space_curve.gif | Bin 1317248 -> 0 bytes .../file2_tangent_space_curve.py | 22 ----- .../file3_tangent_space_curve.gif | Bin 0 -> 1317248 bytes .../file3_tangent_space_curve.py | 33 ++++++++ 7 files changed, 147 insertions(+), 49 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_non_differentiable.py delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.gif create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.py 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 e295c7a..361e2be 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 @@ -1,32 +1,79 @@ from manimlib.imports import * -class arcl(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 10, - "y_min" : 0, - "y_max" : 6, - "graph_origin": ORIGIN, - "x_axis_width": 10, - "y_axis_height": 6 , - "x_tick_frequency": 2, - "y_tick_frequency": 2, - "Func":lambda x : 1+x**1.3*np.exp(-.12*(x-2)**2)*np.sin(x/4), - } +class arcl(MovingCameraScene): def construct(self): - self.setup_axes(hideaxes = True) + # self.setup() def curve_(x): return 3 - (3653*x**2)/5292 + (2477*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (17*x**6)/63504 curve = FunctionGraph(curve_, x_min=-2, x_max=6, stroke_width = 2, color = BLUE).scale(0.1).move_to(ORIGIN) - lines = [Line(length = 0.05, color = RED) for i in range(10)] - lines[0].move_to(np.array([curve_(-2),-2, 0])) + lines = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN).shift(np.array([-4 + 0.1*i, curve_(-2.5 + 0.1*i), 0])).rotate(-25*DEGREES) for i in range(4)] + lines2 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN).shift(np.array([-4 + 0.125*i, curve_(-2.5 + 0.1*i), 0])).rotate(-25*DEGREES) for i in range(4, 9)] + # lines[0].rotate(-25*DEGREES).shift(np.array([-4,curve_(-2.5), 0])) + # lines[1].rotate(-25*DEGREES).shift(np.array([-3.78,curve_(-2.3), 0])) + # lines3 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN + 1.5*UP + 0.6*RIGHT).shift(np.array([-1 + 0.2*i, -1.5 - 0.2*i, 0])).rotate(30*DEGREES) for i in range(4)] + # lines2b = VGroup(*lines3).rotate(-8*DEGREES) + # lines4 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN + 1.6*UP + 0.5*RIGHT).shift(np.array([-1 + 0.18*i, -1.65 - 0.2*i, 0])).rotate(22*DEGREES) for i in range(4, 9)] + # lines5 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN + 7*RIGHT).shift(np.array([-4 + 0.1*i, curve_(-2.5 + 0.1*i), 0])).rotate(-25*DEGREES) for i in range(4)] + # lines6 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN +7.25*RIGHT).shift(np.array([-4 + 0.053*i, curve_(-2.5 + 0.1*i), 0])).rotate(-26*DEGREES) for i in range(4, 9)] + # 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) - # self.play(FadeIn(curve)) - # self.wait(2) - self.play(ApplyMethod(curve.scale, 10)) - self.play(FadeIn(VGroup(*lines))) - self.wait(5) + # l = VGroup(*lines, *lines2, lines2b, *lines4, *lines5, *lines6, lc1b).shift(curve.get_center()) + l = VGroup(*lines, *lines2) + arc = Line(lines[3].get_center(), lines2[0].get_center() + np.array([0.005, 0 ,0]), color = GREEN_SCREEN).rotate(12*DEGREES) + arctext = TextMobject(r'$ds$', color = GREEN_SCREEN).scale(0.15).next_to(arc.get_center(), 0.001*DOWN + 0.01*RIGHT,buff = 0.01) + dy = Arrow(arc.get_start(), np.array([arc.get_start()[0], lines2[0].get_center()[1] + 0.01, 0]), color = YELLOW) + dx = Arrow(arc.get_start(), np.array([lines2[0].get_center()[0] - 0.01, arc.get_start()[1], 0]), color = BLUE) + dxt = DashedLine(dy.get_end(), dy.get_end() + np.array([0.13, 0 ,0])) + 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) + + 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) + + dsd = TextMobject(r'We can divide the curve \\ into multiple small arcs $ds$').scale(0.35).shift(5.2*LEFT + 0.2*UP) + + self.play(FadeIn(curve)) + self.play(ApplyMethod(curve.scale, 10), FadeIn(text)) + # self.play(FadeIn(l)) + self.wait(2) + 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) + 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.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.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.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) + 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]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py index 128fc17..f10fa26 100644 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py @@ -30,7 +30,7 @@ class interpretation(ZoomedScene): dsl = TextMobject(r'$ds$', color = GREEN_SCREEN).scale(0.2).next_to(ds, RIGHT, buff = 0) - tgtText = TextMobject(r'$r\prime (t)$').next_to(tgt, UP, buff = 0).scale(0.7) + tgtText = TextMobject(r'$r\prime (t) = \left\langle 1, 2, 0\right\rangle$').next_to(tgt, UP, buff = 0).scale(0.7) tgt2 = DashedLine((0,0,0),(1, 2, 0), color = GRAY).shift(DOWN + 2*RIGHT) circle = Circle(radius = 0.9, color = GREEN_SCREEN).shift(0.85*RIGHT + 0.38*DOWN) circle.set_stroke(opacity = 1) @@ -49,13 +49,17 @@ class interpretation(ZoomedScene): "$ds$": GREEN_SCREEN }) + main5 = TextMobject(r'$\kappa = 0.357$').scale(0.7).shift(main.get_center() + np.array([2.4,-0.18,0])) + nm = Vector((2, -1, 0), color = BLUE).shift(0.005*RIGHT + 0.007*DOWN) - nmText = TextMobject(r'$r\prime\prime (t)$').next_to(nm, DOWN+RIGHT, buff = 0).scale(0.7) + nmText = TextMobject(r'$r\prime\prime (t) = \left\langle 2,0,0\right\rangle$').next_to(nm, DOWN+RIGHT, buff = 0).scale(0.7) nm2 = DashedLine((0,0,0),(2, -1, 0), color = GRAY).shift(2*UP + RIGHT) square = Square(fill_color = WHITE, fill_opacity = 0.2).rotate(63*DEGREES).shift(0.5*UP +1.5*RIGHT).scale(1.1) square.set_stroke(width = 0.1) + square2 = Square(fill_color = PINK, fill_opacity = 0.2).scale(0.55).rotate(63*DEGREES).move_to((square.get_center() - dot.get_center()) / 2) + square2.set_stroke(width = 0.1) arrow = CurvedArrow(square.get_center() + np.array([2,1,0]), square.get_center() + np.array([0.5,0,0])) - arrowText = TextMobject(r'$r\prime (t)\times r\prime\prime (t)$').next_to(arrow.get_start(), DOWN+1*RIGHT, buff = 0).scale(0.7) + arrowText = TextMobject(r'$r\prime (t)\times r\prime\prime (t) = 4$').next_to(arrow.get_start(), DOWN+1*RIGHT, buff = 0).scale(0.7) text1 = TextMobject(r'$\left|\frac{dT}{ds}\right| = \frac{\left|\frac{dT}{dt}\right|}{\left|\frac{ds}{dt}\right|}$').shift(UP+3*LEFT).scale(0.7) text2 = TextMobject(r'$\left|\frac{dT}{ds}\right| = \frac{\frac{r\prime\prime (t)}{\left| r\prime (t)\right|}\times\frac{r\prime (t)}{\left| r\prime (t)\right|}}{\left|r\prime (t)\right|}$').next_to(text1, DOWN, buff = 0.1).scale(0.7) @@ -74,7 +78,7 @@ class interpretation(ZoomedScene): self.play(FadeIn(main2), FadeIn(dot)) self.play(FadeIn(circle), FadeIn(dl), FadeIn(dltext)) self.wait() - self.play(ReplacementTransform(main2, main3), FadeOut(circle), FadeOut(dl), FadeOut(dltext), FadeIn(VGroup(*[tgt, tgtText]))) + self.play(ReplacementTransform(main2, main5), FadeIn(main3), FadeOut(circle), FadeOut(dl), FadeOut(dltext), FadeIn(VGroup(*[tgt, tgtText]))) self.wait(1) self.play(FadeIn(VGroup(*[nm, nmText]))) self.wait(1) @@ -95,7 +99,7 @@ class interpretation(ZoomedScene): self.wait(1) self.play(FadeIn(VGroup(*[square, arrow, arrowText]))) self.wait(1) - self.play(FadeIn(unit2)) + self.play(FadeIn(unit2), FadeIn(square2)) self.wait(1) self.play(FadeIn(VGroup(*[tgt2text, nm2text]))) self.wait(1) @@ -107,4 +111,4 @@ class interpretation(ZoomedScene): self.wait(1) self.play(FadeIn(text4)) self.wait(2) - self.play(FadeOut(VGroup(*[main, curve, dot, tgt2text, nm2text, text1, text2, text3, text4, tgt, tgtText,nm, nmText,tgt2, nm2,square, arrow, arrowText,unit2]))) + self.play(FadeOut(VGroup(*[main, main5, square2, curve, dot, tgt2text, nm2text, text1, text2, text3, text4, tgt, tgtText,nm, nmText,tgt2, nm2,square, arrow, arrowText,unit2]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_non_differentiable.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_non_differentiable.py new file mode 100644 index 0000000..a91da6b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_non_differentiable.py @@ -0,0 +1,36 @@ +from manimlib.imports import * + +class nd(Scene): + def construct(self): + ld1 = Line().rotate(20*DEGREES) + pd1 = Dot(ld1.get_end(), fill_opacity = 0) + pd1.set_stroke(width = 0.5) + ld2 = Line().rotate(40*DEGREES).shift(1.4*UP + 1.7*RIGHT) + pd2 = Dot(ld2.get_start(), fill_opacity = 1, color = PURPLE) + t1 = TextMobject('A discontinuous function.').scale(0.7).shift(UP + 2*RIGHT) + + obj1 = VGroup(*[ld1, pd1, ld2, pd2]).shift(4*LEFT) + self.play(FadeIn(obj1), FadeIn(t1)) + self.wait(2) + + ld3 = ld2.copy().rotate(-60*DEGREES).shift(1.4*DOWN + 0.2*RIGHT) + pd3 = Dot(ld1.get_end(), fill_opacity = 1, color = PURPLE) + t2 = TextMobject('Graph containing a sharp corner.').scale(0.7).shift( 2*RIGHT) + + obj2 = VGroup(*[ld3, pd3]) + + self.play(Transform(VGroup(*[ld2, pd2]), obj2), ReplacementTransform(t1, t2)) + + self.wait(2) + + ld4 = Line().rotate(90*DEGREES) + pd4 = Dot(ld4.get_center(), color = PURPLE) + a1 = Arc(start_angle = -180*DEGREES, angle = 90*DEGREES).move_to(ld4.get_end()).rotate(-90*DEGREES).shift(0.5*(UP+RIGHT)) + a2 = Arc(start_angle = -180*DEGREES, angle = 90*DEGREES).move_to(ld4.get_start()).rotate(90*DEGREES).shift(0.5*(DOWN+LEFT)) + t3 = TextMobject('Graph with a vertical line.').scale(0.7).shift(2*RIGHT) + + obj3 = VGroup(*[ld4, pd4, a1, a2]).shift(3*LEFT) + + self.play(FadeOut(obj1), Transform(obj2, obj3), ReplacementTransform(t2, t3)) + self.wait(2) + self.play(FadeOut(obj2), FadeOut(t3)) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif deleted file mode 100644 index 06ed70f..0000000 Binary files a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.py deleted file mode 100644 index 67c675e..0000000 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.py +++ /dev/null @@ -1,22 +0,0 @@ -from manimlib.imports import * - -class tangent(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - self.set_camera_orientation(phi = 125*DEGREES, theta = 135*DEGREES) - h = ParametricFunction( - lambda t: np.array([ - 4*(t**3) + 5, - t**2 + 2*(t**4), - -2*np.log(2*t) - ]), t_min = -3, t_max = 1.18 - ).shift(5*LEFT) - tgtR = Line((4,3,-2*np.log(2)), (19.5, 16, -4.772588), color=YELLOW) - tgtL =Line((4,3,-2*np.log(2)), (-11.5, -10, 2), color=YELLOW) - dot = Dot((4,3,-2*np.log(2)), color=RED, radius=0.08) - self.play(FadeIn(axes),FadeIn(h), FadeIn(dot)) - self.begin_ambient_camera_rotation(rate=0.4) - self.wait(2) - self.play(FadeIn(tgtL), FadeIn(tgtR)) - self.wait(5) - self.play(FadeOut(axes), FadeOut(h), FadeOut(dot), FadeOut(tgtL), FadeOut(tgtR)) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.gif new file mode 100644 index 0000000..06ed70f Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.gif differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.py new file mode 100644 index 0000000..c3aecc6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.py @@ -0,0 +1,33 @@ +from manimlib.imports import * + +class tangent(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + text = TextMobject(r'Tangent', r' to the ', 'space curve', r' \\ at point ', r'$P_{1}$', ' is given by:').scale(0.7).shift(3*UP + 3.5*LEFT) + text.set_color_by_tex_to_color_map({ + "Tangent": YELLOW, + '$P_{1}$': RED, + 'space curve': BLUE + }) + text.bg=BackgroundRectangle(text,fill_opacity=1, color = BLACK) + text_gr =VGroup(text.bg,text) + self.set_camera_orientation(phi = 125*DEGREES, theta = 135*DEGREES) + h = ParametricFunction( + lambda t: np.array([ + 4*(t**3) + 5, + t**2 + 2*(t**4), + -2*np.log(2*t) + ]), t_min = -3, t_max = 1.18, color = BLUE + ).shift(5*LEFT) + tgtR = Line((4,3,-2*np.log(2)), (19.5, 16, -4.772588), color=YELLOW) + tgtL =Line((4,3,-2*np.log(2)), (-11.5, -10, 2), color=YELLOW) + dot = Dot((4,3,-2*np.log(2)), color=RED, radius=0.08) + dotl = TextMobject(r'$P_{1}$', color = RED).scale(0.7).shift(2*DOWN + 5*LEFT) + self.add_fixed_in_frame_mobjects(text_gr, dotl) + self.play(FadeIn(axes),FadeIn(h), FadeIn(dot), FadeIn(dotl)) + self.wait(2) + self.play(FadeIn(tgtL), FadeIn(tgtR)) + self.begin_ambient_camera_rotation(rate=0.2) + self.play(FadeOut(dotl)) + self.wait(5) + self.play(FadeOut(axes), FadeOut(h), FadeOut(text_gr), FadeOut(dot), FadeOut(tgtL), FadeOut(tgtR)) -- cgit