From 8096534204aeb06ea8e4b7a25c5bf4f7f1d52ffb Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Wed, 1 Jul 2020 18:49:14 +0530 Subject: arc length video --- .../arc-length-and-curvature/file1_arc_length.py | 325 +++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py (limited to 'FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.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 new file mode 100644 index 0000000..75c19aa --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py @@ -0,0 +1,325 @@ +# Contribution creidts: Somnath Pandit + +from manimlib.imports import * + + +class LineIntegrationAsSum(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 10, + "y_min" : 0, + "y_max" : 6, + "graph_origin": ORIGIN+5*LEFT+3*DOWN, + "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), + "a": 1 ,"b": 9, "n": 15, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + self.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + curve=self.get_graph( + self.Func, + x_min=self.a, + x_max=self.b, + ) + curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) + curve_label= self.get_graph_label( + curve, + label="\\text{Curve for integration:}", + x_val=4, + direction=UR, + buff=.6, + color=BLUE + ) + self.curve=curve + self.curve_label=curve_label + + self.get_vector_field() + + + self.play(ShowCreation(VGroup(curve,curve_label))) + self.wait(.6) + self.break_in_arcs() + self.show_the_sum() + + self.wait(2) + + + def get_vector_field(self): + func = lambda v: np.array([ + v[0], # x + -v[1], # y + 0 # z + ]) + vector_field= VectorField( + func, + delta_x=1, + delta_y=1, + colors=[GREEN_A,GREEN_C], + length_func= lambda norm: .8*sigmoid(norm), + vector_config={ + "stroke_width": 2 + } + ) + + self.vector_field= vector_field + + + def break_in_arcs(self): + + self.write_about_breaking() + + dl=0.8 + self.get_breakers(dl) + self.wait(2) + self.play(FadeOut(self.upto_break_text)) + self.dl=dl + + def write_about_breaking(self): + breaking_text=TextMobject("\\texttt{is broken}"," into small ", "subarcs") + breaking_text.set_color_by_tex_to_color_map({ + "broken":RED,"subarcs": BLUE + }) + breaking_text.next_to(self.curve_label,DOWN) + breaking_text.align_to(self.curve_label,LEFT) + self.play( + Write(breaking_text) + ) + + self.upto_break_text=VGroup( + self.curve_label, + breaking_text, + ) + + def get_breakers(self,dl): + point=self.a + points=[] + while point<(self.b-dl) : + start=point + end=point+dl + points += [end] + breaker=Line( + self.input_to_graph_point(start,self.curve), + self.input_to_graph_point(end,self.curve), + stroke_width=2, + color=RED, + ) + breaker.rotate(PI/2).scale(.5) + + point=end + self.play(FadeIn(breaker),run_time=.2) + # self.add(breaker) + + del points[-1] + self.points=points + + + def show_the_sum(self): + at_any_points_text=TextMobject("At an arbitrary ","point", " in each ", "subarc") + at_any_points_text.set_color_by_tex_to_color_map({ + "point":YELLOW , "subarc": BLUE + }) + at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) + + evaluate_text=TextMobject("$\\vec F(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) + evaluate_text.set_color_by_tex("$\\vec F(x,y)$",ORANGE) + + multiply_text=TextMobject("...is multiplied with ","$\\Delta s_i$") + multiply_text.set_color_by_tex("\\Delta s_i", BLUE) + multiply_text.next_to(at_any_points_text,DOWN) + + + + self.at_any_points_text=at_any_points_text + self.evaluate_text=evaluate_text + self.multiply_text=multiply_text + + dots=[] + for point in self.points: + + dot=Dot( + point=self.input_to_graph_point(point,self.curve), + radius= .7*DEFAULT_DOT_RADIUS, + stroke_width= 0, + fill_opacity= 1.0, + color= YELLOW, + ) + dots+=[dot] + + self.play( + Write(at_any_points_text), + FadeIn(VGroup(*dots)),run_time=1.5 + ) + self.dots=dots + + self.wait() + self.show_the_dot_product() + self.multiply_with_ds() + self.construct_equation() + + + def show_the_dot_product(self): + index=-(len(self.points)//3) + self.index=index + + dot=self.dots[index] + + + dot_prod_text=TextMobject("Dot product of ", "$\\vec F(x_i,y_i)$", " and ","$\\vec T(x_i,y_i)$") + dot_prod_text.set_color_by_tex_to_color_map({ + "\\vec F(x_i,y_i)":ORANGE , + "\\vec T(x_i,y_i)": "#DC75CD" , + }) + dot_prod_text.to_edge(TOP,buff=SMALL_BUFF) + + + point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) + point_coord.next_to(dot,DL,buff=.01).scale(.8) + + func_val=TextMobject("$\\vec F(x_i,y_i)$",color=ORANGE) + func_val.next_to(dot,UR).scale(.8) + + self.dot_prod_text=dot_prod_text + self.func_val=func_val + + dot.set_color(ORANGE).scale(1.2) + + + self.play(FadeIn(VGroup(point_coord,dot))) + self.play(Write(self.evaluate_text)) + self.wait(1) + self.play(FadeOut(self.vector_field)) + self.get_vector_and_tangent() + self.dot_product() + + + self.wait(2) + self.remove(point_coord) + + + def get_vector_and_tangent(self): + dot=self.dots[self.index] + self.show_specific_vectors(dot) + self.play(Write(self.func_val)) + self.wait(1) + self.show_tangent(dot) + self.play(FadeIn(VGroup(*[ + dot.set_color(ORANGE).scale(1.4) + for dot in self.dots ] + ))) + + + def show_specific_vectors(self,dots): + for dot in dots: + vector=self.vector_field.get_vector(dot.get_center()) + vector.set_color(ORANGE) + + self.play(Write(vector),run_time=.2) + + + def show_tangent(self,dot): + tangent_sym=TextMobject("$\\vec T(x_i,y_i)$",color="#DC75CD").scale(.8) + x=dot.get_center() + angle=self.angle_of_tangent( + self.point_to_coords(x)[0], + self.curve, + dx=0.01 + ) + vect = Vector().rotate(angle,about_point=x) + vect.set_color("#DC75CD") + tangent=vect.next_to(x,DR,buff=0) + tangent_sym.next_to(tangent,DOWN,buff=.1) + self.play(Write(VGroup(tangent,tangent_sym))) + + self.tangent_sym=tangent_sym + + def dot_product(self): + + dot_sym=Dot().next_to(self.func_val,RIGHT) + + self.play(FadeOut(VGroup( + self.at_any_points_text, + self.evaluate_text + ))) + self.play(Write(self.dot_prod_text)) + self.play( + FadeIn(dot_sym), + ApplyMethod( + self.tangent_sym.next_to, + dot_sym, RIGHT + )) + + self.dot_sym=dot_sym + + def multiply_with_ds(self): + self.get_ds() + + self.play(GrowFromCenter(self.ds_brace_group)) + self.wait(2) + self.play(Write(self.multiply_text)) + self.play(ApplyMethod( + self.ds_brace_label.next_to, + self.tangent_sym, RIGHT,buff=.15 + )) + + + + def get_ds(self): + p1= self.dots[self.index] + p2= self.dots[self.index+1] + ds_brace=Brace(VGroup(p1,p2),DL) + ds_brace.move_to(p1,UR) + ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) + ds_brace_label.set_color(BLUE) + self.ds_brace=ds_brace + self.ds_brace_label=ds_brace_label + self.ds_brace_group=VGroup(ds_brace,ds_brace_label) + + + def construct_equation(self): + sum_up_text=TextMobject("and"," summed ", "for all `i's") + sum_up_text.set_color_by_tex("summed",PURPLE_A) + sum_up_text.next_to(self.multiply_text,DOWN,buff=MED_SMALL_BUFF) + sum_up_text.shift(LEFT) + + sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE_A) + sum_eqn.move_to(self.graph_origin+6.5*self.X+4*self.Y) + + line_integral_text=TextMobject("The"," line ","integral's value is: ").to_edge(TOP,buff=MED_SMALL_BUFF) + line_integral_text.set_color_by_tex("line",BLUE_C) + approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) + multipled=VGroup( + self.func_val, + self.dot_sym, + self.tangent_sym, + self.ds_brace_label + ) + + + self.play(Write(sum_up_text)) + self.show_specific_vectors(self.dots) + self.play(FadeIn(sum_eqn)) + self.play(ApplyMethod( + multipled.next_to,sum_eqn,RIGHT + )) + self.wait() + self.play(FadeOut(VGroup( + self.dot_prod_text, + self.multiply_text, + sum_up_text + ))) + self.play(Write(line_integral_text)) + self.play(FadeIn(approx)) + + + +#uploaded by Somnath Pandit.FSF2020_Line Integrals -- cgit From 05080cd0751a9ebd7acf9c94790461038aa9a069 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Sat, 4 Jul 2020 02:13:27 +0530 Subject: tnb, curvature interpretation --- .../arc-length-and-curvature/file1_arc_length.py | 319 +-------------------- 1 file changed, 13 insertions(+), 306 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.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 75c19aa..e295c7a 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,325 +1,32 @@ -# Contribution creidts: Somnath Pandit - from manimlib.imports import * -class LineIntegrationAsSum(GraphScene): +class arcl(GraphScene): CONFIG = { "x_min" : 0, "x_max" : 10, "y_min" : 0, "y_max" : 6, - "graph_origin": ORIGIN+5*LEFT+3*DOWN, + "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), - "a": 1 ,"b": 9, "n": 15, } - def construct(self): - X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) - Y = UP*self.y_axis_height/(self.y_max- self.y_min) - self.X=X ;self.Y=Y - - self.setup_axes(animate=False) - - - curve=self.get_graph( - self.Func, - x_min=self.a, - x_max=self.b, - ) - curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) - curve_label= self.get_graph_label( - curve, - label="\\text{Curve for integration:}", - x_val=4, - direction=UR, - buff=.6, - color=BLUE - ) - self.curve=curve - self.curve_label=curve_label - - self.get_vector_field() - - - self.play(ShowCreation(VGroup(curve,curve_label))) - self.wait(.6) - self.break_in_arcs() - self.show_the_sum() - - self.wait(2) - - - def get_vector_field(self): - func = lambda v: np.array([ - v[0], # x - -v[1], # y - 0 # z - ]) - vector_field= VectorField( - func, - delta_x=1, - delta_y=1, - colors=[GREEN_A,GREEN_C], - length_func= lambda norm: .8*sigmoid(norm), - vector_config={ - "stroke_width": 2 - } - ) - - self.vector_field= vector_field - - - def break_in_arcs(self): - - self.write_about_breaking() - - dl=0.8 - self.get_breakers(dl) - self.wait(2) - self.play(FadeOut(self.upto_break_text)) - self.dl=dl - - def write_about_breaking(self): - breaking_text=TextMobject("\\texttt{is broken}"," into small ", "subarcs") - breaking_text.set_color_by_tex_to_color_map({ - "broken":RED,"subarcs": BLUE - }) - breaking_text.next_to(self.curve_label,DOWN) - breaking_text.align_to(self.curve_label,LEFT) - self.play( - Write(breaking_text) - ) - - self.upto_break_text=VGroup( - self.curve_label, - breaking_text, - ) - - def get_breakers(self,dl): - point=self.a - points=[] - while point<(self.b-dl) : - start=point - end=point+dl - points += [end] - breaker=Line( - self.input_to_graph_point(start,self.curve), - self.input_to_graph_point(end,self.curve), - stroke_width=2, - color=RED, - ) - breaker.rotate(PI/2).scale(.5) - - point=end - self.play(FadeIn(breaker),run_time=.2) - # self.add(breaker) - - del points[-1] - self.points=points - - - def show_the_sum(self): - at_any_points_text=TextMobject("At an arbitrary ","point", " in each ", "subarc") - at_any_points_text.set_color_by_tex_to_color_map({ - "point":YELLOW , "subarc": BLUE - }) - at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) - - evaluate_text=TextMobject("$\\vec F(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) - evaluate_text.set_color_by_tex("$\\vec F(x,y)$",ORANGE) - - multiply_text=TextMobject("...is multiplied with ","$\\Delta s_i$") - multiply_text.set_color_by_tex("\\Delta s_i", BLUE) - multiply_text.next_to(at_any_points_text,DOWN) - - - - self.at_any_points_text=at_any_points_text - self.evaluate_text=evaluate_text - self.multiply_text=multiply_text - - dots=[] - for point in self.points: - - dot=Dot( - point=self.input_to_graph_point(point,self.curve), - radius= .7*DEFAULT_DOT_RADIUS, - stroke_width= 0, - fill_opacity= 1.0, - color= YELLOW, - ) - dots+=[dot] - - self.play( - Write(at_any_points_text), - FadeIn(VGroup(*dots)),run_time=1.5 - ) - self.dots=dots - - self.wait() - self.show_the_dot_product() - self.multiply_with_ds() - self.construct_equation() - - - def show_the_dot_product(self): - index=-(len(self.points)//3) - self.index=index - - dot=self.dots[index] - - - dot_prod_text=TextMobject("Dot product of ", "$\\vec F(x_i,y_i)$", " and ","$\\vec T(x_i,y_i)$") - dot_prod_text.set_color_by_tex_to_color_map({ - "\\vec F(x_i,y_i)":ORANGE , - "\\vec T(x_i,y_i)": "#DC75CD" , - }) - dot_prod_text.to_edge(TOP,buff=SMALL_BUFF) - - - point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) - point_coord.next_to(dot,DL,buff=.01).scale(.8) - - func_val=TextMobject("$\\vec F(x_i,y_i)$",color=ORANGE) - func_val.next_to(dot,UR).scale(.8) - - self.dot_prod_text=dot_prod_text - self.func_val=func_val - - dot.set_color(ORANGE).scale(1.2) - - - self.play(FadeIn(VGroup(point_coord,dot))) - self.play(Write(self.evaluate_text)) - self.wait(1) - self.play(FadeOut(self.vector_field)) - self.get_vector_and_tangent() - self.dot_product() - - - self.wait(2) - self.remove(point_coord) - - - def get_vector_and_tangent(self): - dot=self.dots[self.index] - self.show_specific_vectors(dot) - self.play(Write(self.func_val)) - self.wait(1) - self.show_tangent(dot) - self.play(FadeIn(VGroup(*[ - dot.set_color(ORANGE).scale(1.4) - for dot in self.dots ] - ))) - - - def show_specific_vectors(self,dots): - for dot in dots: - vector=self.vector_field.get_vector(dot.get_center()) - vector.set_color(ORANGE) - - self.play(Write(vector),run_time=.2) - - - def show_tangent(self,dot): - tangent_sym=TextMobject("$\\vec T(x_i,y_i)$",color="#DC75CD").scale(.8) - x=dot.get_center() - angle=self.angle_of_tangent( - self.point_to_coords(x)[0], - self.curve, - dx=0.01 - ) - vect = Vector().rotate(angle,about_point=x) - vect.set_color("#DC75CD") - tangent=vect.next_to(x,DR,buff=0) - tangent_sym.next_to(tangent,DOWN,buff=.1) - self.play(Write(VGroup(tangent,tangent_sym))) - - self.tangent_sym=tangent_sym - - def dot_product(self): - - dot_sym=Dot().next_to(self.func_val,RIGHT) - - self.play(FadeOut(VGroup( - self.at_any_points_text, - self.evaluate_text - ))) - self.play(Write(self.dot_prod_text)) - self.play( - FadeIn(dot_sym), - ApplyMethod( - self.tangent_sym.next_to, - dot_sym, RIGHT - )) - - self.dot_sym=dot_sym - - def multiply_with_ds(self): - self.get_ds() - - self.play(GrowFromCenter(self.ds_brace_group)) - self.wait(2) - self.play(Write(self.multiply_text)) - self.play(ApplyMethod( - self.ds_brace_label.next_to, - self.tangent_sym, RIGHT,buff=.15 - )) - - - - def get_ds(self): - p1= self.dots[self.index] - p2= self.dots[self.index+1] - ds_brace=Brace(VGroup(p1,p2),DL) - ds_brace.move_to(p1,UR) - ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) - ds_brace_label.set_color(BLUE) - self.ds_brace=ds_brace - self.ds_brace_label=ds_brace_label - self.ds_brace_group=VGroup(ds_brace,ds_brace_label) - - - def construct_equation(self): - sum_up_text=TextMobject("and"," summed ", "for all `i's") - sum_up_text.set_color_by_tex("summed",PURPLE_A) - sum_up_text.next_to(self.multiply_text,DOWN,buff=MED_SMALL_BUFF) - sum_up_text.shift(LEFT) - - sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE_A) - sum_eqn.move_to(self.graph_origin+6.5*self.X+4*self.Y) - - line_integral_text=TextMobject("The"," line ","integral's value is: ").to_edge(TOP,buff=MED_SMALL_BUFF) - line_integral_text.set_color_by_tex("line",BLUE_C) - approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) - multipled=VGroup( - self.func_val, - self.dot_sym, - self.tangent_sym, - self.ds_brace_label - ) - + self.setup_axes(hideaxes = True) + 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 - self.play(Write(sum_up_text)) - self.show_specific_vectors(self.dots) - self.play(FadeIn(sum_eqn)) - self.play(ApplyMethod( - multipled.next_to,sum_eqn,RIGHT - )) - self.wait() - self.play(FadeOut(VGroup( - self.dot_prod_text, - self.multiply_text, - sum_up_text - ))) - self.play(Write(line_integral_text)) - self.play(FadeIn(approx)) + 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])) -#uploaded by Somnath Pandit.FSF2020_Line Integrals + # self.play(FadeIn(curve)) + # self.wait(2) + self.play(ApplyMethod(curve.scale, 10)) + self.play(FadeIn(VGroup(*lines))) + self.wait(5) -- cgit 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 +++++++++++++++++----- 1 file changed, 68 insertions(+), 21 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.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]))) -- cgit From 5fce21eac898c754fc661dfdb6162aaafc82b06e Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Tue, 7 Jul 2020 21:33:20 +0530 Subject: arc length final --- .../arc-length-and-curvature/file1_arc_length.py | 100 +++++++++++++++------ 1 file changed, 72 insertions(+), 28 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.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 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]))) -- cgit