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.gif | Bin 0 -> 822369 bytes .../arc-length-and-curvature/file1_arc_length.py | 325 +++++++++++++++++++++ .../file1_simple_visualization.gif | Bin 675451 -> 0 bytes .../file1_simple_visualization.py | 69 ----- .../file2_circle_curvature.gif | Bin 346667 -> 0 bytes .../file2_circle_curvature.py | 27 -- .../file2_simple_visualization.gif | Bin 0 -> 675451 bytes .../file2_simple_visualization.py | 69 +++++ .../file3_circle_curvature.gif | Bin 0 -> 346667 bytes .../file3_circle_curvature.py | 27 ++ .../file3_curvature_interpretation.gif | Bin 700862 -> 0 bytes .../file3_curvature_interpretation.py | 42 --- .../file4_curvature_interpretation.gif | Bin 0 -> 700862 bytes .../file4_curvature_interpretation.py | 42 +++ .../file4_different_curvature_single_curve.gif | Bin 243868 -> 0 bytes .../file4_different_curvature_single_curve.py | 78 ----- .../file5_different_curvature_single_curve.gif | Bin 0 -> 243868 bytes .../file5_different_curvature_single_curve.py | 76 +++++ 18 files changed, 539 insertions(+), 216 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.gif create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.py delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.gif create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.gif create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.py delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.gif delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.gif create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.gif create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.py (limited to 'FSF-2020/calculus-of-several-variables') diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.gif new file mode 100644 index 0000000..bbad112 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.gif differ 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 diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif deleted file mode 100644 index 3f7ecd1..0000000 Binary files a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.py deleted file mode 100644 index 45058d7..0000000 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.py +++ /dev/null @@ -1,69 +0,0 @@ -from manimlib.imports import * - -class randomcurve(GraphScene): - CONFIG = { - "x_min": -4, - "x_max": 6, - "y_min": -6, - "y_max": 10, - "graph_origin": ORIGIN - } - def construct(self): - intro = TextMobject('Consider the following curve.') - mid = TextMobject(r'Notice how the direction of the unit tangent vectors\\changes with respect to the arc length.') - outro = TextMobject(r'The rate of change of unit tangents with \\ respect to the arc length $ds$ is called curvature.\\Mathematically, curvature $ = k = \left|{\frac{dT}{ds}}\right|$') - - XTD = self.x_axis_width/(self.x_max- self.x_min) - YTD = self.y_axis_height/(self.y_max- self.y_min) - - tgt1 = Arrow((-2.2*XTD,-0.5*YTD,0),(-1*XTD,1,0)) - tgt2 = Arrow((-1.2*XTD, 1.93*YTD,0),(0*XTD,1.6,0)).scale(1.2) - tgt3 = Arrow((-0.3*XTD,3*YTD, 0), (1.5*XTD, 3*YTD,0)) - tgt4 = Arrow((1.4*XTD, 2*YTD,0),(2.4*XTD, 1*YTD,0)).scale(2.8) - tgt5 = Arrow((2.4*XTD, 0, 0), (3.8*XTD,-2*YTD, 0)).scale(1.2).shift(0.26*RIGHT) - tgt6 = Arrow((3.8*XTD,-1*YTD, 0), (4.8*XTD, -1*YTD, 0)).scale(2.8).shift(0.26*RIGHT) - tgt7 = Arrow((5.3*XTD, 0, 0),(6.3*XTD,1,0)).shift(0.35*LEFT+0.1*DOWN).scale(1.3) - - dot1 = Dot(tgt1.get_start(), color = RED) - dot2 = Dot(tgt2.get_start(), color = RED) - dot3 = Dot(tgt3.get_start(), color = RED) - dot4 = Dot(tgt4.get_start(), color = RED) - dot5 = Dot(tgt5.get_start(), color = RED) - dot6 = Dot(tgt6.get_start(), color = RED) - dot7 = Dot(tgt7.get_start(), color = RED) - - arc = ArcBetweenPoints(dot1.get_center(), dot2.get_center(), color = GREEN_SCREEN, angle = 10*DEGREES).rotate(180*DEGREES) - - dots = VGroup(*[dot1, dot2, dot3, dot4, dot5, dot6, dot7]) - - ds = CurvedArrow((-4, 2, 0), (tgt1.get_start() + tgt2.get_start()) / 2, color = YELLOW) - ds_text = TextMobject(r'$ds$').next_to(ds, UP, buff = 0.1).shift(1.3*LEFT) - - self.setup_axes(hideaxes=True) - graphobj = self.get_graph(self.curve) - self.play(FadeIn(intro)) - self.wait(2) - self.play(FadeOut(intro)) - self.setup_axes(hideaxes=False) - self.play(ShowCreation(graphobj), FadeIn(dots), FadeIn(ds), FadeIn(ds_text), FadeIn(arc)) - self.wait(1) - self.play(FadeOut(self.axes), FadeOut(arc), FadeOut(graphobj),FadeIn(mid), FadeOut(dots), FadeOut(ds), FadeOut(ds_text)) - self.wait(3) - self.play(FadeOut(mid)) - self.play(FadeIn(self.axes), FadeIn(graphobj), FadeIn(dots)) - - tangents = [tgt1, tgt2, tgt3, tgt4, tgt5, tgt6, tgt7] - for tangent in tangents: - self.play(ShowCreation(tangent), run_time = 0.2) - self.wait(1) - tangents = VGroup(*tangents) - self.play(FadeOut(self.axes), FadeOut(graphobj), FadeOut(tangents), FadeOut(dots)) - self.wait(1) - self.play(FadeIn(outro)) - self.wait(3) - self.play(FadeOut(outro)) - self.wait(1) - - - def curve(self, x): - return 3 - (3653*x**2)/5292 + (2477*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (17*x**6)/63504 diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif deleted file mode 100644 index 989a3b7..0000000 Binary files a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.py deleted file mode 100644 index 232ac41..0000000 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.py +++ /dev/null @@ -1,27 +0,0 @@ -from manimlib.imports import * - -class circleC(GraphScene): - CONFIG = { - "x_min": -6, - "x_max": 6, - "y_min": -6, - "y_max": 6, - "graph_origin": ORIGIN, - "x_axis_width": 12, - "y_axis_height": 12 - } - def construct(self): - epiphany = TextMobject(r'Driving a vehicle on which of \\ the two paths would be easier?').scale(0.6).shift(3.5*LEFT + 3*UP) - outro = TextMobject(r'The larger path, due to its \\ smaller curvature, since $k = \frac{1}{R}$.').scale(0.6).shift(3.7*LEFT + 3*UP) - XTD = self.x_axis_width/(self.x_max- self.x_min) - YTD = self.y_axis_height/(self.y_max- self.y_min) - - circle = Circle(radius = 2, color = BLUE) - circle2 = Circle(radius = 3, color = GREEN_E) - - self.setup_axes(hideaxes=True) - self.play(FadeIn(self.axes), Write(circle, run_time = 2), FadeIn(epiphany)) - self.play(Write(circle2, run_time = 3)) - self.play(ReplacementTransform(epiphany, outro)) - self.wait(2) - self.play(FadeOut(VGroup(*[self.axes, circle, circle2, epiphany, outro]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.gif new file mode 100644 index 0000000..3f7ecd1 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.gif differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py new file mode 100644 index 0000000..45058d7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py @@ -0,0 +1,69 @@ +from manimlib.imports import * + +class randomcurve(GraphScene): + CONFIG = { + "x_min": -4, + "x_max": 6, + "y_min": -6, + "y_max": 10, + "graph_origin": ORIGIN + } + def construct(self): + intro = TextMobject('Consider the following curve.') + mid = TextMobject(r'Notice how the direction of the unit tangent vectors\\changes with respect to the arc length.') + outro = TextMobject(r'The rate of change of unit tangents with \\ respect to the arc length $ds$ is called curvature.\\Mathematically, curvature $ = k = \left|{\frac{dT}{ds}}\right|$') + + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + tgt1 = Arrow((-2.2*XTD,-0.5*YTD,0),(-1*XTD,1,0)) + tgt2 = Arrow((-1.2*XTD, 1.93*YTD,0),(0*XTD,1.6,0)).scale(1.2) + tgt3 = Arrow((-0.3*XTD,3*YTD, 0), (1.5*XTD, 3*YTD,0)) + tgt4 = Arrow((1.4*XTD, 2*YTD,0),(2.4*XTD, 1*YTD,0)).scale(2.8) + tgt5 = Arrow((2.4*XTD, 0, 0), (3.8*XTD,-2*YTD, 0)).scale(1.2).shift(0.26*RIGHT) + tgt6 = Arrow((3.8*XTD,-1*YTD, 0), (4.8*XTD, -1*YTD, 0)).scale(2.8).shift(0.26*RIGHT) + tgt7 = Arrow((5.3*XTD, 0, 0),(6.3*XTD,1,0)).shift(0.35*LEFT+0.1*DOWN).scale(1.3) + + dot1 = Dot(tgt1.get_start(), color = RED) + dot2 = Dot(tgt2.get_start(), color = RED) + dot3 = Dot(tgt3.get_start(), color = RED) + dot4 = Dot(tgt4.get_start(), color = RED) + dot5 = Dot(tgt5.get_start(), color = RED) + dot6 = Dot(tgt6.get_start(), color = RED) + dot7 = Dot(tgt7.get_start(), color = RED) + + arc = ArcBetweenPoints(dot1.get_center(), dot2.get_center(), color = GREEN_SCREEN, angle = 10*DEGREES).rotate(180*DEGREES) + + dots = VGroup(*[dot1, dot2, dot3, dot4, dot5, dot6, dot7]) + + ds = CurvedArrow((-4, 2, 0), (tgt1.get_start() + tgt2.get_start()) / 2, color = YELLOW) + ds_text = TextMobject(r'$ds$').next_to(ds, UP, buff = 0.1).shift(1.3*LEFT) + + self.setup_axes(hideaxes=True) + graphobj = self.get_graph(self.curve) + self.play(FadeIn(intro)) + self.wait(2) + self.play(FadeOut(intro)) + self.setup_axes(hideaxes=False) + self.play(ShowCreation(graphobj), FadeIn(dots), FadeIn(ds), FadeIn(ds_text), FadeIn(arc)) + self.wait(1) + self.play(FadeOut(self.axes), FadeOut(arc), FadeOut(graphobj),FadeIn(mid), FadeOut(dots), FadeOut(ds), FadeOut(ds_text)) + self.wait(3) + self.play(FadeOut(mid)) + self.play(FadeIn(self.axes), FadeIn(graphobj), FadeIn(dots)) + + tangents = [tgt1, tgt2, tgt3, tgt4, tgt5, tgt6, tgt7] + for tangent in tangents: + self.play(ShowCreation(tangent), run_time = 0.2) + self.wait(1) + tangents = VGroup(*tangents) + self.play(FadeOut(self.axes), FadeOut(graphobj), FadeOut(tangents), FadeOut(dots)) + self.wait(1) + self.play(FadeIn(outro)) + self.wait(3) + self.play(FadeOut(outro)) + self.wait(1) + + + def curve(self, x): + return 3 - (3653*x**2)/5292 + (2477*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (17*x**6)/63504 diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.gif new file mode 100644 index 0000000..989a3b7 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.gif differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.py new file mode 100644 index 0000000..232ac41 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.py @@ -0,0 +1,27 @@ +from manimlib.imports import * + +class circleC(GraphScene): + CONFIG = { + "x_min": -6, + "x_max": 6, + "y_min": -6, + "y_max": 6, + "graph_origin": ORIGIN, + "x_axis_width": 12, + "y_axis_height": 12 + } + def construct(self): + epiphany = TextMobject(r'Driving a vehicle on which of \\ the two paths would be easier?').scale(0.6).shift(3.5*LEFT + 3*UP) + outro = TextMobject(r'The larger path, due to its \\ smaller curvature, since $k = \frac{1}{R}$.').scale(0.6).shift(3.7*LEFT + 3*UP) + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + circle = Circle(radius = 2, color = BLUE) + circle2 = Circle(radius = 3, color = GREEN_E) + + self.setup_axes(hideaxes=True) + self.play(FadeIn(self.axes), Write(circle, run_time = 2), FadeIn(epiphany)) + self.play(Write(circle2, run_time = 3)) + self.play(ReplacementTransform(epiphany, outro)) + self.wait(2) + self.play(FadeOut(VGroup(*[self.axes, circle, circle2, epiphany, outro]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.gif deleted file mode 100644 index 22a450a..0000000 Binary files a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.py deleted file mode 100644 index d8dd0a4..0000000 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.py +++ /dev/null @@ -1,42 +0,0 @@ -from manimlib.imports import * - -class interpretation(Scene): - def construct(self): - tgt = Vector((1, 2, 0), color = YELLOW) - tgtText = TextMobject(r'$r\prime (t)$').next_to(tgt, UP, buff = 0).scale(0.7) - tgt2 = DashedLine((0,0,0),(1, 2, 0), color = GRAY).shift(DOWN + 2*RIGHT) - - nm = Vector((2, -1, 0), color = BLUE) - nmText = TextMobject(r'$r\prime\prime (t)$').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) - 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) - - text1 = TextMobject(r'$\left|\frac{dT}{ds}\right| = \frac{\left|\frac{dT}{dt}\right|}{\left|\frac{ds}{dt}\right|}$').shift(UP+3*LEFT) - 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) - unit = VGroup(*[tgt, tgt2, nm, nm2]) - - # self.play(FadeIn(VGroup(*[tgt, tgt2, nm, nm2, nmText, tgtText, square, arrow, arrowText]))) - tgt2text = TextMobject(r'$\frac{r\prime (t)}{\left| r\prime (t)\right|}$').shift(1.1*UP).scale(0.7).rotate(63*DEGREES ) - nm2text = TextMobject(r'$\frac{r\prime\prime (t)}{\left| r\prime (t)\right|}$').scale(0.7).shift(0.7*RIGHT+0.8*DOWN).rotate(-25*DEGREES) - unit2 = unit.copy().scale(0.5).shift(0.75*LEFT+0.25*DOWN) - - self.play(FadeIn(VGroup(*[tgt, tgtText]))) - self.wait(1) - self.play(FadeIn(VGroup(*[nm, nmText]))) - self.wait(1) - self.play(FadeIn(VGroup(*[tgt2, nm2]))) - self.wait(1) - self.play(FadeIn(VGroup(*[square, arrow, arrowText]))) - self.wait(1) - self.play(FadeIn(unit2)) - self.wait(1) - self.play(FadeIn(VGroup(*[tgt2text, nm2text]))) - self.wait(1) - self.play(FadeIn(text1)) - self.wait(1) - self.play(FadeIn(text2)) - self.wait(2) - self.play(FadeOut(VGroup(*[tgt2text, nm2text, text1, text2, tgt, tgtText,nm, nmText,tgt2, nm2,square, arrow, arrowText,unit2]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.gif new file mode 100644 index 0000000..22a450a Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.gif differ 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 new file mode 100644 index 0000000..d8dd0a4 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py @@ -0,0 +1,42 @@ +from manimlib.imports import * + +class interpretation(Scene): + def construct(self): + tgt = Vector((1, 2, 0), color = YELLOW) + tgtText = TextMobject(r'$r\prime (t)$').next_to(tgt, UP, buff = 0).scale(0.7) + tgt2 = DashedLine((0,0,0),(1, 2, 0), color = GRAY).shift(DOWN + 2*RIGHT) + + nm = Vector((2, -1, 0), color = BLUE) + nmText = TextMobject(r'$r\prime\prime (t)$').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) + 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) + + text1 = TextMobject(r'$\left|\frac{dT}{ds}\right| = \frac{\left|\frac{dT}{dt}\right|}{\left|\frac{ds}{dt}\right|}$').shift(UP+3*LEFT) + 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) + unit = VGroup(*[tgt, tgt2, nm, nm2]) + + # self.play(FadeIn(VGroup(*[tgt, tgt2, nm, nm2, nmText, tgtText, square, arrow, arrowText]))) + tgt2text = TextMobject(r'$\frac{r\prime (t)}{\left| r\prime (t)\right|}$').shift(1.1*UP).scale(0.7).rotate(63*DEGREES ) + nm2text = TextMobject(r'$\frac{r\prime\prime (t)}{\left| r\prime (t)\right|}$').scale(0.7).shift(0.7*RIGHT+0.8*DOWN).rotate(-25*DEGREES) + unit2 = unit.copy().scale(0.5).shift(0.75*LEFT+0.25*DOWN) + + self.play(FadeIn(VGroup(*[tgt, tgtText]))) + self.wait(1) + self.play(FadeIn(VGroup(*[nm, nmText]))) + self.wait(1) + self.play(FadeIn(VGroup(*[tgt2, nm2]))) + self.wait(1) + self.play(FadeIn(VGroup(*[square, arrow, arrowText]))) + self.wait(1) + self.play(FadeIn(unit2)) + self.wait(1) + self.play(FadeIn(VGroup(*[tgt2text, nm2text]))) + self.wait(1) + self.play(FadeIn(text1)) + self.wait(1) + self.play(FadeIn(text2)) + self.wait(2) + self.play(FadeOut(VGroup(*[tgt2text, nm2text, text1, text2, tgt, tgtText,nm, nmText,tgt2, nm2,square, arrow, arrowText,unit2]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif deleted file mode 100644 index 3b78b5f..0000000 Binary files a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.py deleted file mode 100644 index 56b7fbb..0000000 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.py +++ /dev/null @@ -1,78 +0,0 @@ -from manimlib.imports import * - -class GR(GraphScene): - CONFIG = { - "x_axis_label": "", - "y_axis_label": "", - "x_min": -4, - "x_max": 6, - "y_min": -6, - "y_max": 10, - "graph_origin": ORIGIN, - 'x_tick_frequency': 20, - 'y_tick_frequency': 20 - } - - def construct(self): - - self.setup_axes() - 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 - - graph = FunctionGraph(curve, x_min=-3, x_max=6, stroke_width = 2, color = BLUE) - - tracker = ValueTracker(-3) - - text = TextMobject(r'$\because R_{1} > R_{2}$, the curvature at \\ point $P_{1}$ is less than that \\ at point $P_{2}$ as $\kappa = \frac{1}{R}$').shift(3.2*RIGHT+3*UP).scale(0.6) - - dot1 = Dot((0,3,0), color = YELLOW) - dot1label = TextMobject(r'$P_{1}$').next_to(dot1, UP+RIGHT, buff = 0.1) - dot2 = Dot((4,-1, 0), color = YELLOW) - dot2label = TextMobject(r'$P_{2}$').next_to(dot2, DOWN, buff = 0.1) - dots = VGroup(*[dot1, dot2, dot1label, dot2label]) - - def get_tangent_line(): - line = Line( - ORIGIN, 2 * RIGHT, - color=RED, - stroke_width=4, - ) - dx = 0.0001 - - x = tracker.get_value() - p0 = np.array([x-dx,curve(x-dx),0]) - p1 = np.array([x, curve(x), 0]) - p2 = np.array([x + dx, curve(x + dx), 0]) - - angle = angle_of_vector(p2 - p1) - line.rotate(angle) - line.move_to(p0) - return line - - circle1 = Circle(radius = 0.8, color = GREY, opacity = 0.2).shift(2.2*UP) - tgt1 = Line((-2,3,0), (2,3,0), color = GREY, opacity = 0.2).scale(0.4) - - r1 = Line(circle1.get_center(), circle1.get_center() + np.array([0,0.8,0]), color=GREEN_SCREEN) - r1label = TextMobject(r'$R_{1}$',color=WHITE).next_to(r1, RIGHT, buff = 0.1).scale(0.6) - - curvature1 = VGroup(*[circle1, tgt1, r1, r1label]) - - circle2 = Circle(radius = 0.6, color = GREY, opacity = 0.2).shift(0.4*DOWN + 4*RIGHT) - tgt2 = Line((4,-2,0), (6, -2, 0), color = GREY, opacity = 0.2).scale(0.5).shift(LEFT + UP) - - r2 = Line(circle2.get_center(), circle2.get_center() + np.array([0,-0.6,0]), color=GREEN_SCREEN) - r2label = TextMobject(r'$R_{2}$', color=WHITE).next_to(r2, 0.9*RIGHT, buff = 0).scale(0.6) - - curvature2 = VGroup(*[circle2, tgt2, r2, r2label]) - - line = always_redraw(get_tangent_line) - - self.add(graph,line, dots, text) - self.wait(1.2) - self.play(tracker.set_value, 0, rate_func=smooth, run_time=5) - self.play(FadeIn(curvature1)) - self.play(tracker.set_value, 4, rate_func=smooth, run_time=5) - self.play(FadeIn(curvature2)) - self.play(tracker.set_value, 6, rate_func=smooth, run_time=3) - self.play(FadeOut(VGroup(*[curvature1, curvature2, graph, self.axes, line, dots, text]))) - self.wait() diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.gif new file mode 100644 index 0000000..3b78b5f Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.gif differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.py new file mode 100644 index 0000000..0dc06bb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.py @@ -0,0 +1,76 @@ +from manimlib.imports import * + +class GR(GraphScene): + CONFIG = { + "x_axis_label": "", + "y_axis_label": "", + "x_min": -4, + "x_max": 6, + "y_min": -6, + "y_max": 10, + "graph_origin": ORIGIN, + 'x_tick_frequency': 20, + 'y_tick_frequency': 20 + } + + def construct(self): + + self.setup_axes() + def curve(x): + return 3 - (3653*x**2)/5292 + (277*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (170*x**6)/63504 + + graph = FunctionGraph(curve, x_min=-2, x_max=6, stroke_width = 2, color = BLUE) + + tracker = ValueTracker(-2) + + text = TextMobject(r'$\because R_{1} > R_{2}$, the curvature at \\ point $P_{1}$ is less than that \\ at point $P_{2}$ as $\kappa = \frac{1}{R}$').shift(3.2*LEFT+3*UP).scale(0.6) + + dot1 = Dot((0,3,0), color = YELLOW) + dot1label = TextMobject(r'$P_{1}$').next_to(dot1, UP+RIGHT, buff = 0.1) + dot2 = Dot((2.9,-0.47, 0), color = YELLOW) + dot2label = TextMobject(r'$P_{2}$').next_to(dot2, DOWN, buff = 0.1) + dots = VGroup(*[dot1, dot2, dot1label, dot2label]) + + def get_tangent_line(): + line = Line( + ORIGIN, 2 * RIGHT, + color=RED, + stroke_width=4, + ) + dx = 0.0001 + + x = tracker.get_value() + p0 = np.array([x-dx,curve(x-dx),0]) + p1 = np.array([x, curve(x), 0]) + p2 = np.array([x + dx, curve(x + dx), 0]) + + angle = angle_of_vector(p2 - p1) + line.rotate(angle) + line.move_to(p0) + return line + + circle1 = Circle(radius = 0.8, color = GREY, opacity = 0.2).shift(2.2*UP) + tgt1 = Line((-2,3,0), (2,3,0), color = GREY, opacity = 0.2).scale(0.4) + + r1 = Line(circle1.get_center(), circle1.get_center() + np.array([0,0.8,0]), color=GREEN_SCREEN) + r1label = TextMobject(r'$R_{1}$',color=WHITE).next_to(r1, RIGHT, buff = 0.1).scale(0.6) + + curvature1 = VGroup(*[circle1, tgt1, r1, r1label]) + + circle2 = Circle(radius = 0.2, color = GREY, opacity = 0.2).shift(0.3*DOWN + 2.9*RIGHT) + tgt2 = Line((4,-2,0), (6, -2, 0), color = GREY, opacity = 0.2).scale(0.5).shift(2.1*LEFT + 1.5*UP) + + r2 = Line(circle2.get_center(), circle2.get_center() - np.array([0,0.2,0]), color=GREEN_SCREEN) + r2label = TextMobject(r'$R_{2}$', color=WHITE).next_to(r2.get_start(), np.array([0,0,0]), buff = 0).scale(0.4) + + curvature2 = VGroup(*[circle2, tgt2, r2, r2label]) + + line = always_redraw(get_tangent_line) + + self.add(graph, line, dots, text) + self.wait(1.2) + self.play(tracker.set_value, 4, rate_func=smooth, run_time=10) + self.play(FadeIn(curvature1), FadeIn(curvature2)) + self.wait(2) + self.play(FadeOut(VGroup(*[curvature1, curvature2, graph, self.axes, line, dots, text]))) + self.wait() -- 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 +-------------------- .../file2_simple_visualization.py | 60 ++-- .../file4_curvature_interpretation.py | 86 +++++- .../file3_tnb_frame_manim.py | 112 +++++++- 4 files changed, 233 insertions(+), 344 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables') 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) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py index 45058d7..05cad80 100644 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py @@ -1,8 +1,8 @@ from manimlib.imports import * -class randomcurve(GraphScene): +class a(GraphScene): CONFIG = { - "x_min": -4, + "x_min": -3, "x_max": 6, "y_min": -6, "y_max": 10, @@ -10,12 +10,15 @@ class randomcurve(GraphScene): } def construct(self): intro = TextMobject('Consider the following curve.') - mid = TextMobject(r'Notice how the direction of the unit tangent vectors\\changes with respect to the arc length.') - outro = TextMobject(r'The rate of change of unit tangents with \\ respect to the arc length $ds$ is called curvature.\\Mathematically, curvature $ = k = \left|{\frac{dT}{ds}}\right|$') + mid = TextMobject(r'Notice how the direction of the unit tangent vector\\changes with respect to the arc length.') + outro = TextMobject(r'The rate of change of unit tangent with \\ respect to the arc length $ds$ is called curvature.\\Mathematically, curvature $ = k = \left|{\frac{dT}{ds}}\right|$') XTD = self.x_axis_width/(self.x_max- self.x_min) YTD = self.y_axis_height/(self.y_max- self.y_min) + circle = Circle(radius = 0.95, color = GRAY, fill_opacity = 0.2, fill_color = RED) + circle.set_stroke(width = 0.1) + tgt1 = Arrow((-2.2*XTD,-0.5*YTD,0),(-1*XTD,1,0)) tgt2 = Arrow((-1.2*XTD, 1.93*YTD,0),(0*XTD,1.6,0)).scale(1.2) tgt3 = Arrow((-0.3*XTD,3*YTD, 0), (1.5*XTD, 3*YTD,0)) @@ -40,30 +43,49 @@ class randomcurve(GraphScene): ds_text = TextMobject(r'$ds$').next_to(ds, UP, buff = 0.1).shift(1.3*LEFT) self.setup_axes(hideaxes=True) - graphobj = self.get_graph(self.curve) + + 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 + + # parabola_x_out = FunctionGraph(curve, x_min=-2, x_max=6, stroke_width = 2, color = BLUE) + parabola_x_out = self.get_graph(curve) + + dot_x = Dot().rotate(PI/2).set_color(YELLOW_E) + alpha_x = ValueTracker(-2) + vector_x = self.get_tangent_vector(alpha_x.get_value(),parabola_x_out,scale=1.5) + dot_x.add_updater(lambda m: m.move_to(vector_x.get_center())) + vector_x.add_updater( + lambda m: m.become( + self.get_tangent_vector(alpha_x.get_value()%1,parabola_x_out,scale=1.5) + ) + ) + self.play(FadeIn(intro)) self.wait(2) self.play(FadeOut(intro)) self.setup_axes(hideaxes=False) - self.play(ShowCreation(graphobj), FadeIn(dots), FadeIn(ds), FadeIn(ds_text), FadeIn(arc)) - self.wait(1) - self.play(FadeOut(self.axes), FadeOut(arc), FadeOut(graphobj),FadeIn(mid), FadeOut(dots), FadeOut(ds), FadeOut(ds_text)) + self.play(ShowCreation(parabola_x_out), FadeIn(dots), FadeIn(ds), FadeIn(ds_text), FadeIn(arc)) + self.wait(2) + self.play(FadeOut(self.axes), FadeOut(arc), FadeOut(parabola_x_out),FadeIn(mid), FadeOut(dots), FadeOut(ds), FadeOut(ds_text)) self.wait(3) self.play(FadeOut(mid)) - self.play(FadeIn(self.axes), FadeIn(graphobj), FadeIn(dots)) - - tangents = [tgt1, tgt2, tgt3, tgt4, tgt5, tgt6, tgt7] - for tangent in tangents: - self.play(ShowCreation(tangent), run_time = 0.2) - self.wait(1) - tangents = VGroup(*tangents) - self.play(FadeOut(self.axes), FadeOut(graphobj), FadeOut(tangents), FadeOut(dots)) - self.wait(1) + self.play(FadeIn(self.axes), FadeIn(parabola_x_out), FadeIn(dots)) + self.add(vector_x) + self.play(alpha_x.increment_value, 1, run_time=8, rate_func=linear) + self.remove(vector_x) + self.play(FadeOut(VGroup(*[self.axes, dots, parabola_x_out]))) self.play(FadeIn(outro)) self.wait(3) self.play(FadeOut(outro)) self.wait(1) - def curve(self, x): - return 3 - (3653*x**2)/5292 + (2477*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (17*x**6)/63504 + + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i , coord_i + unit_vector, color = YELLOW, buff=0) + return vector 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 d8dd0a4..128fc17 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 @@ -1,12 +1,55 @@ from manimlib.imports import * -class interpretation(Scene): +class interpretation(ZoomedScene): + CONFIG = { + "zoomed_display_height": 3, + "zoomed_display_width": 3, + "zoom_factor": 0.15, + "zoomed_display_center": ORIGIN + 4*LEFT + DOWN, + } def construct(self): - tgt = Vector((1, 2, 0), color = YELLOW) + + tgt = Vector((1, 2, 0), color = YELLOW).shift(0.005*RIGHT + 0.007*DOWN) + dot = Dot(tgt.get_start(),color = RED) + curve = ParametricFunction( + lambda t: np.array([ + 2*(t**2), + 4*t, + 0 + ]), t_min = -5, t_max = 5 + ).scale(0.3).move_to(ORIGIN + 4*RIGHT).rotate(6*DEGREES) + + ds = ParametricFunction( + lambda t: np.array([ + 2*(t**2), + 4*t, + 0 + ]), t_min = 0, t_max = 0.05, color = GREEN_SCREEN + ).scale(0.9).shift(3.09*LEFT).rotate(-27.5*DEGREES).move_to(ORIGIN).shift(0.07*UP + 0.05*RIGHT).set_stroke(width=20) + + 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) 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) + dl = DashedLine(circle.get_center(), dot.get_center()) + dltext = TextMobject(r'$R = 2.795$').scale(0.5).next_to(circle.get_center(), DOWN, buff = 0.1) + + main = TextMobject(r'r(t) = $\left\langle t^{2}, 2t, 0 \right\rangle\quad r\prime (t) = \left\langle 2t, 2, 0 \right\rangle\quad$ \\ $r\prime\prime (t) = \left\langle 2, 0, 0 \right\rangle$').scale(0.7).shift(3*UP + 3*LEFT) + main2 = TextMobject(r'Curvature at an arbitrary point \\ say r(t = 0.5) can be given as: \\ $\kappa = \frac{1}{R} = \frac{1}{2.795} = 0.357$').scale(0.7).shift(3.5*LEFT) + main3 = TextMobject(r'The ', 'tangent', r' and ', 'normal', r' vectors \\ can be represented as:').scale(0.7).shift(3.5*LEFT) + main3.set_color_by_tex_to_color_map({ + "tangent": YELLOW, + "normal": BLUE + }) + main4 = TextMobject(r'These vectors travel along \\ a small interval ', r'$ds$').scale(0.7).shift(1.5*UP + 3*LEFT) + main4.set_color_by_tex_to_color_map({ + "$ds$": GREEN_SCREEN + }) - nm = Vector((2, -1, 0), color = BLUE) + 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) 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) @@ -14,20 +57,41 @@ class interpretation(Scene): 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) - text1 = TextMobject(r'$\left|\frac{dT}{ds}\right| = \frac{\left|\frac{dT}{dt}\right|}{\left|\frac{ds}{dt}\right|}$').shift(UP+3*LEFT) - 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) + 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) + text3 = TextMobject(r'$= \frac{4}{(4t^{2} + 4)^{\frac{3}{2}}}$ \\ $= \frac{1}{2\sqrt{(1 + (0.5)^{2})^{3}}}$').next_to(text2, DOWN, buff = 0.1).scale(0.7) + text4 = TextMobject(r'$ = 0.357$').scale(0.7).next_to(text3, DOWN, buff = 0.2) unit = VGroup(*[tgt, tgt2, nm, nm2]) - # self.play(FadeIn(VGroup(*[tgt, tgt2, nm, nm2, nmText, tgtText, square, arrow, arrowText]))) tgt2text = TextMobject(r'$\frac{r\prime (t)}{\left| r\prime (t)\right|}$').shift(1.1*UP).scale(0.7).rotate(63*DEGREES ) nm2text = TextMobject(r'$\frac{r\prime\prime (t)}{\left| r\prime (t)\right|}$').scale(0.7).shift(0.7*RIGHT+0.8*DOWN).rotate(-25*DEGREES) unit2 = unit.copy().scale(0.5).shift(0.75*LEFT+0.25*DOWN) - self.play(FadeIn(VGroup(*[tgt, tgtText]))) + self.play(FadeIn(curve), FadeIn(main)) + self.wait(1) + self.play(ApplyMethod(curve.scale, 3), ApplyMethod(curve.shift, ORIGIN + 3.31*RIGHT)) + # self.wait(2) + 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.wait(1) self.play(FadeIn(VGroup(*[nm, nmText]))) self.wait(1) - self.play(FadeIn(VGroup(*[tgt2, nm2]))) + self.remove(dot) + self.setup() + #self.camera_frame.set_width(4) + self.activate_zooming(animate = True) + self.play(FadeIn(ds), FadeIn(dsl), FadeOut(main3)) + self.wait(1) + self.play(FadeIn(main4)) + self.play(ApplyMethod(tgt.shift, 0.16*UP + 0.09*RIGHT), ApplyMethod(nm.shift, 0.16*UP + 0.09*RIGHT), run_time = 5) + self.wait(1) + self.play(FadeOut(ds), FadeOut(dsl), FadeOut(main4), FadeOut(self.zoomed_display, run_time = 1), FadeOut(self.zoomed_camera.frame, run_time = 1)) + # tgt = tgt.shift(0.16*DOWN + 0.08*LEFT) + # nm = nm.shift(0.16*DOWN + 0.08*LEFT) + self.play(ApplyMethod(tgt.shift, 0.16*DOWN + 0.09*LEFT, run_time = 1), ApplyMethod(nm.shift, 0.16*DOWN + 0.09*LEFT, run_time = 1)) + self.play(FadeIn(dot), FadeIn(VGroup(*[tgt2, nm2]))) self.wait(1) self.play(FadeIn(VGroup(*[square, arrow, arrowText]))) self.wait(1) @@ -38,5 +102,9 @@ class interpretation(Scene): self.play(FadeIn(text1)) self.wait(1) self.play(FadeIn(text2)) + self.wait(1) + self.play(FadeIn(text3)) + self.wait(1) + self.play(FadeIn(text4)) self.wait(2) - self.play(FadeOut(VGroup(*[tgt2text, nm2text, text1, text2, tgt, tgtText,nm, nmText,tgt2, nm2,square, arrow, arrowText,unit2]))) + self.play(FadeOut(VGroup(*[main, 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/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.py index 176cac5..091c1e2 100644 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.py +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.py @@ -11,6 +11,9 @@ class tnb(ThreeDScene): text = VGroup(*[t,n,b,frame]).move_to(ORIGIN).shift(3*UP) + c1 = TextMobject(r'$r(t) = \left\langle\cos{t}, \sin{t}, 0.4t\right\rangle\quad r\prime (t) =\left\langle -\sin{t}, \cos{t}, 0.4\right\rangle$').next_to(text, DOWN, buff = 0.1).scale(0.7) + + helix1 = ParametricFunction( lambda t: np.array([ np.cos(TAU*t), @@ -53,6 +56,95 @@ class tnb(ThreeDScene): helix_dot = Dot(radius = 0.16, color = RED) + t_tracker = ValueTracker(-2*np.pi/3) + t=t_tracker.get_value + + # t_label = TexMobject( + # "t = ",color=WHITE + # ).next_to(helix1,DOWN, buff=0.2).scale(0.6) + + cval1 = TextMobject(r'r(').next_to(c1, DOWN+16.5*LEFT, buff = 0.1).scale(0.7) + + t_text = always_redraw( + lambda: DecimalNumber( + t(), + color=WHITE, + ).next_to(cval1, RIGHT, buff=0.05).scale(0.7) + ).scale(0.6) + + + cval2 = always_redraw( + lambda: TextMobject(r') = $\left\langle$').scale(0.7).next_to(t_text, RIGHT, buff = 0.05) + ) + + cos = always_redraw( + lambda: DecimalNumber( + np.cos(t()), + color=WHITE, + ).next_to(cval2, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + sin = always_redraw( + lambda: DecimalNumber( + np.sin(t()), + color=WHITE, + ).next_to(cos, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + zpart = always_redraw( + lambda: DecimalNumber( + 0.4* t(), + color=WHITE, + ).next_to(sin, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + cvalend = always_redraw( + lambda: TextMobject(r' $\right\rangle$').next_to(zpart, RIGHT, buff = 0.2).scale(0.7) + ).scale(0.6) + + + valgroup = VGroup(*[cval1, cval2,cos,sin,zpart, cvalend]) + + rp1 = always_redraw( + lambda: TextMobject(r'$r\prime ($').scale(0.7).next_to(cvalend, RIGHT, buff = 0.6) + ) + + t_text2 = always_redraw( + lambda: DecimalNumber( + t(), + color=WHITE, + ).next_to(rp1, RIGHT, buff=0.05).scale(0.7) + ).scale(0.6) + + rp2 = always_redraw( + lambda: TextMobject(r') = $\left\langle$').scale(0.7).next_to(t_text2, RIGHT, buff = 0.05) + ) + + rps = always_redraw( + lambda: DecimalNumber( + -np.sin(t()), + color=WHITE, + ).next_to(rp2, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + + rpc = always_redraw( + lambda: DecimalNumber( + np.cos(t()), + color=WHITE, + ).next_to(rps, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + + const = always_redraw( + lambda: TextMobject(r'0.4 $\right\rangle$').next_to(rpc, RIGHT, buff = 0.2).scale(0.7) + ).scale(0.6).shift(0.1*DOWN) + + val2group = VGroup(*[rp1, rp2, rps, rpc, const]) + + #group = VGroup(t_text, t_text2).scale(1.5).move_to(ORIGIN).shift(3.7*DOWN) + + dot0 = Dot(np.array([np.cos(-2*np.pi/3), np.sin(-2*np.pi/3), -0.8*np.pi/3]), radius = 0.16, color=RED).shift(np.array([4.65,0,-0.8])) tgt0 = Arrow((0,0,0), (1,2,0), color = YELLOW).shift(dot0.get_center() - np.array([0.04,0.2,0])) nm0 = Arrow((0,0,0), (-2,1,0), color = BLUE).shift(dot0.get_center() + np.array([0.3,0,0])) @@ -75,20 +167,20 @@ class tnb(ThreeDScene): point2 = VGroup(*[dot2, tgt2, nm2, bnm2, plane2]) helix = VGroup(*[helix1, helix2, helix3, helix4, helix5]) - self.add_fixed_in_frame_mobjects(text) - self.play(FadeIn(helix), FadeIn(text)) + self.add_fixed_in_frame_mobjects(text, c1) + self.play(FadeIn(helix), FadeIn(text), FadeIn(c1)) self.play(ApplyMethod(helix.scale, 4)) - self.add_fixed_in_frame_mobjects(bnm0) - self.play(FadeIn(point0)) - self.play(ApplyMethod(point0.set_color, GRAY, opacity = 0.1), MoveAlongPath(helix_dot, helix1, run_time=5)) + self.add_fixed_in_frame_mobjects(bnm0, valgroup, val2group, t_text, t_text2) + self.play(FadeIn(point0), FadeIn(t_text), FadeIn(t_text2), FadeIn(valgroup), FadeIn(val2group)) + self.play(ApplyMethod(point0.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix1, run_time=5), t_tracker.set_value,-1.638*np.pi/3, rate_func=linear, run_time=5) self.add_fixed_in_frame_mobjects(bnm1) self.play(FadeIn(point1)) - self.play(ApplyMethod(point1.set_color, GRAY, opacity = 0.1), ApplyMethod(bnm1.set_color, GRAY, opacity = 0.1), MoveAlongPath(helix_dot, helix2, run_time = 5)) + self.play(ApplyMethod(point1.set_color, GRAY, opacity = 0.1, run_time = 0.5), ApplyMethod(bnm1.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix2, run_time = 5), t_tracker.set_value,-1.33*np.pi/3, rate_func=linear, run_time=5) self.add_fixed_in_frame_mobjects(bnm2) self.play(FadeIn(point2)) - self.play(ApplyMethod(point2.set_color, GRAY, opacity = 0.1), MoveAlongPath(helix_dot, helix3, run_time=5)) + self.play(ApplyMethod(point2.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix3, run_time=5), t_tracker.set_value,-np.pi/3, rate_func=linear, run_time=5) dot3 = Dot(np.array([np.cos(-np.pi/3), np.sin(-np.pi/3), -0.4*np.pi/3]) + np.array([3.3,-0.25,0]), radius = 0.16, color=RED) tgt3 = Arrow((0,0,0), (0,2,0), color = YELLOW).shift(helix_dot.get_center() - np.array([-0.05,0.2,0])) @@ -113,14 +205,14 @@ class tnb(ThreeDScene): self.add_fixed_in_frame_mobjects(bnm3) self.play(FadeIn(point3)) - self.play(ApplyMethod(point3.set_color, GRAY, opacity = 0.1), MoveAlongPath(helix_dot, helix4, run_time=5)) + self.play(ApplyMethod(point3.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix4, run_time=5), t_tracker.set_value,-1.3*np.pi/6, rate_func=linear, run_time=5) self.add_fixed_in_frame_mobjects(bnm4) self.play(FadeIn(point4)) - self.play(ApplyMethod(point4.set_color, GRAY, opacity = 0.1), MoveAlongPath(helix_dot, helix5, run_time=5)) + self.play(ApplyMethod(point4.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix5, run_time=5), t_tracker.set_value,0, rate_func=linear, run_time=5) self.add_fixed_in_frame_mobjects(bnm5) self.play(FadeIn(point5)) self.wait(2) - self.play(FadeOut(VGroup(*[text, helix, bnm1, point0, point1, point2, point3, point4, point5, helix_dot]))) + self.play(FadeOut(VGroup(*[valgroup, val2group, t_text, t_text2, c1, text, helix, bnm1, point0, point1, point2, point3, point4, point5, helix_dot]))) -- 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 ++++++++++++++++----- .../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 (limited to 'FSF-2020/calculus-of-several-variables') 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 From ab0319a54739b8471de779f55d43091867cac72b Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Tue, 7 Jul 2020 14:52:22 +0530 Subject: Update README.md --- .../velocity-and-differentiability/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables') diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md index bc571c6..02678fd 100644 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md @@ -1,2 +1,2 @@ -**file2_tangent_space_curve.py**
-![file2_tangent_space_curve.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif) +**file3_tangent_space_curve.py**
+![file3_tangent_space_curve.py](https://github.com/saarthdeshpande/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.gif) -- 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') 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 From 20cadd4f6ec5cc626445a8115d4e25083843fe70 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Mon, 13 Jul 2020 19:43:48 +0530 Subject: velocity updated, tnb torsion, fs1 --- .../file4_fs1.gif | Bin 551048 -> 0 bytes .../file4_fs1.py | 104 ++++++++++++++---- .../file5_fs2.gif | Bin 629437 -> 0 bytes .../file5_fs2.py | 28 ----- .../file6_torsion_intuition.py | 119 +++++++++++++++++++++ 5 files changed, 205 insertions(+), 46 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.gif delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.gif delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py (limited to 'FSF-2020/calculus-of-several-variables') diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.gif deleted file mode 100644 index 6b4b438..0000000 Binary files a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.py index c719a1d..f3f5a9c 100644 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.py +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.py @@ -1,23 +1,91 @@ from manimlib.imports import * - -class fs1(ThreeDScene): +class fs1(GraphScene): + CONFIG = { + "x_min": -2, + "x_max": 2, + "y_min": -6, + "y_max": 6, + "graph_origin": ORIGIN + } def construct(self): + text = TextMobject(r'$\frac{dT}{ds} = \kappa N$ \\ $\frac{dT}{ds}$ gives the direction of N, \\ while $\kappa$ gives its magnitude.').scale(0.7).shift(3*UP + 3*LEFT) + + self.setup_axes() + def curve_(x): + return x**3 - 2*x + + def nm(x): + return abs(6 * x / ((9*(x**4) - 6*(x**2) + 5)**1.5)) + + figure = self.get_graph(curve_) + + + dot = Dot().rotate(PI/2) + alpha = ValueTracker(0) + t2_ = ValueTracker(-2) + t2 = t2_.get_value + t = alpha.get_value + vector_x = self.get_tangent_vector(t(),figure,scale=2) + vector_y = self.get_normal_vector(t(),figure,scale=2) - self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) - dot1 = Dot(np.array([np.cos(-np.pi/3), np.sin(-np.pi/3), -0.4*np.pi/3]) + np.array([0,0.2,0]), radius = 0.16, color=RED) - tgt1 = Arrow((0,0,0), (-2,-0.55,0), color = YELLOW).shift(dot1.get_center() + np.array([0.18,0.04,0])) - nm1 = Arrow((0,0,0), (0.4,-2,0), color = BLUE).shift(dot1.get_center() + np.array([0,0.26,0])).shift(np.array([0.8,4.76,0])).rotate(-15*DEGREES).scale(0.8) - bnm1 = Arrow((0,0,0), (0,2,0), color=GREEN_E).shift(2.1*RIGHT+2*DOWN) - plane1 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot1.get_center() + np.array([-0.4, -0.6, 0])).rotate(13*DEGREES).scale(1.2) - point1 = VGroup(*[dot1, tgt1, plane1]).scale(0.8).shift(np.array([1,4.86,0])).rotate(-15*DEGREES) - t = TextMobject(r'$T$', color = YELLOW).move_to(ORIGIN).shift(3.2*RIGHT + DOWN) - n = TextMobject(r'$N$', color = BLUE).shift(DOWN + RIGHT) - b = TextMobject(r'$B$', color = GREEN_E).next_to(bnm1, UP, buff = 0.1) - text = VGroup(*[t, n, b]) - self.add_fixed_in_frame_mobjects(bnm1, text) - self.play(FadeIn(point1), FadeIn(bnm1), FadeIn(text)) - self.wait() - self.play(TransformFromCopy(tgt1, nm1, run_time = 2)) + kappa = TextMobject(r'$\kappa = $').scale(0.7).shift(3*DOWN + 3*RIGHT) + + t_text = always_redraw( + lambda: DecimalNumber( + nm(t2()), + color=WHITE, + ).scale(0.7).next_to(kappa) + ).scale(0.6) + + self.play( + ShowCreation(figure), + GrowFromCenter(dot), + GrowArrow(vector_x), + GrowArrow(vector_y) + ) + vector_x.add_updater( + lambda m: m.become( + self.get_tangent_vector(t(),figure,scale=2) + ) + ) + vector_y.add_updater( + lambda m: m.become( + self.get_normal_vector(t(),figure,scale=2) + ) + ) + dot.add_updater(lambda m: m.move_to(vector_x.get_start())) + circle = Circle(radius = 2, color = GREEN_SCREEN). shift(2.63*RIGHT + 2.8*UP) + dot2 = Dot(np.array([2, curve_(2), 0]), color = WHITE).shift(2*DOWN + 2.5*RIGHT) + + self.add(vector_x, vector_y,dot, t_text, kappa, text) + self.play(t2_.set_value, 2, alpha.set_value, 1, run_time=18, rate_func=smooth) + self.play(FadeIn(dot2), FadeIn(circle)) self.wait(2) - self.play(FadeOut(VGroup(*[bnm1, text, point1, nm1]))) + self.play(FadeOut(VGroup(*[self.axes, dot2, figure, circle, text, kappa, t_text]))) + + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=0.5): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * 0.7 + vector = Arrow(coord_i , coord_i + unit_vector, color = YELLOW, buff=0) + return vector + + def get_normal_vector(self, proportion, curve, dx=0.001, scale=1): + t = proportion.copy()/6 + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + length = 6 * t / ((9*(t**4) - 6*(t**2) + 5)**1.5) + if coord_i[0] <= 0 and coord_i[0] > -0.5: + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(0).scale(2) + elif coord_i[0] > 0 and (coord_i[0] < 0.5 or coord_i[0] > 2.7): + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(0).scale(2) + elif coord_i[0] > 0: + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(length).scale(2) + else: + reference_line = Line(coord_i,coord_f).rotate(-PI/2).set_width(length).scale(2) + unit_vector = reference_line.get_vector() * scale + vector = Arrow(coord_i , coord_i + unit_vector, color = RED_C, buff=0) + return vector diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.gif deleted file mode 100644 index ce367b6..0000000 Binary files a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.py deleted file mode 100644 index 0261fed..0000000 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_fs2.py +++ /dev/null @@ -1,28 +0,0 @@ -from manimlib.imports import * - -class fs1(ThreeDScene): - def construct(self): - - - self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) - dot1 = Dot(np.array([np.cos(-np.pi/3), np.sin(-np.pi/3), -0.4*np.pi/3]) + np.array([0,0.2,0]), radius = 0.16, color=RED) - tgt1 = Arrow((0,0,0), (-2,-0.55,0), color = YELLOW).shift(dot1.get_center() + np.array([0.18,0.04,0])) - nm1 = Arrow((0,0,0), (0.4,-2,0), color = BLUE).shift(dot1.get_center() + np.array([0,0.26,0])).shift(np.array([0.8,4.76,0])).rotate(-15*DEGREES).scale(0.8) - bnm1 = Arrow((0,0,0), (0,2,0), color=GREEN_E).shift(2.1*RIGHT+2*DOWN) - - bnms = Line((0,0,0), (0,0,1.6), color = GREEN_E).shift(np.array([3.1,5.2,0])).scale(0.6) - bnmsa = ArrowTip(color = GREEN_E).next_to(bnms, np.array([0,0,1]), buff = 0).rotate(45*DEGREES) - bns = VGroup(*[bnms, bnmsa]) - - plane1 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot1.get_center() + np.array([-0.4, -0.6, 0])).rotate(13*DEGREES).scale(1.2) - point1 = VGroup(*[dot1, tgt1, plane1]).scale(0.8).shift(np.array([1,4.86,0])).rotate(-15*DEGREES) - t = TextMobject(r'$T$', color = YELLOW).move_to(ORIGIN).shift(3.2*RIGHT + DOWN) - n = TextMobject(r'$N$', color = BLUE).shift(DOWN + RIGHT) - b = TextMobject(r'$B$', color = GREEN_E).next_to(bnm1, UP, buff = 0.1) - text = VGroup(*[t, n, b]) - self.add_fixed_in_frame_mobjects(bnm1, text) - self.play(FadeIn(point1), FadeIn(text), FadeIn(bnm1)) - self.wait() - self.play(TransformFromCopy(bnms, nm1, run_time = 3)) - self.wait(2) - self.play(FadeOut(VGroup(*[bnms, text, point1, nm1, bnm1]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py new file mode 100644 index 0000000..31b9a85 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py @@ -0,0 +1,119 @@ +from manimlib.imports import * + +class t(SpecialThreeDScene): + CONFIG = { + "axes_config": { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "z_min": -4, + "z_max": 4, + "x_axis_config": { + "tick_frequency": 100, + }, + "y_axis_config": { + "tick_frequency": 100, + }, + "z_axis_config": { + "tick_frequency": 100, + }, + "num_axis_pieces": 1, + } + } + def construct(self): + + text = TextMobject(r'Torsion can be intuitively \\ thought of as the measure \\ of "twisting" of a curve.').scale(0.7).shift(2.5*UP + 4.2*LEFT) + + + dot = Dot().rotate(PI/2) + f1 = ParametricFunction( + lambda t: np.array([ + 2*np.sin(TAU*t), + 2*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d1 = Dot(color = RED).next_to(f1.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.4*RIGHT) + t1 = self.get_torsion(2, 0.174) + t1 = "{:.2f}".format(t1) + t1 = TextMobject(fr'At the given point, $\tau = {t1}$').shift(3.5*DOWN).scale(0.7) + + f2 = ParametricFunction( + lambda t: np.array([ + 3*np.sin(TAU*t), + 3*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d2 = Dot(color = RED).next_to(f2.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.95*RIGHT) + t2 = self.get_torsion(3, 0.1765) + t2 = "{:.2f}".format(t2) + t2 = TextMobject(fr'At the given point, $\tau = {t2}$').shift(3.5*DOWN).scale(0.7) + + f3 = ParametricFunction( + lambda t: np.array([ + 4*np.sin(TAU*t), + 4*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d3 = Dot(color = RED).next_to(f3.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 3.45*RIGHT) + t3 = self.get_torsion(4, 0.179) + t3 = "{:.2f}".format(t3) + t3 = TextMobject(fr'At the given point, $\tau = {t3}$').shift(3.5*DOWN).scale(0.7) + + f4 = ParametricFunction( + lambda t: np.array([ + 1.5*np.sin(TAU*t), + 1.5*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d4 = Dot(color = RED).next_to(f4.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.215*UP + 2.128*RIGHT) + t4 = self.get_torsion(1.5, 0.173) + t4 = "{:.2f}".format(t4) + t4 = TextMobject(fr'At the given point, $\tau = {t4}$').shift(3.5*DOWN).scale(0.7) + + f5 = ParametricFunction( + lambda t: np.array([ + np.sin(TAU*t), + np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + + d5 = Dot(color = RED).next_to(f5.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.3*UP + 1.858*RIGHT) + t5 = self.get_torsion(1, 0.17) + t5 = "{:.2f}".format(t5) + t5 = TextMobject(fr'At the given point, $\tau = {t5}$').shift(3.5*DOWN).scale(0.7) + + axes = ThreeDAxes(**self.axes_config) + self.set_camera_orientation(phi = 60*DEGREES, theta=45*DEGREES) + self.add_fixed_in_frame_mobjects(t1, text) + self.play(FadeIn(VGroup(*[f1, d1, t1, axes, text]))) + self.wait(2) + self.add_fixed_in_frame_mobjects(t2) + self.play(ReplacementTransform(d1, d2), ReplacementTransform(f1, f2), ReplacementTransform(t1, t2)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t3) + self.play(ReplacementTransform(d2, d3), ReplacementTransform(f2, f3), ReplacementTransform(t2, t3)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t4) + self.play(ReplacementTransform(d3, d4), ReplacementTransform(f3, f4), ReplacementTransform(t3, t4)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t5) + self.play(ReplacementTransform(d4, d5), ReplacementTransform(f4, f5), ReplacementTransform(t4, t5)) + self.wait(2) + self.play(FadeOut(VGroup(*[d5, f5, t5, text, axes]))) + + def get_torsion(self, a, t): + rprime = np.array([a*np.cos(t), -a*np.sin(t), 2]) + T = rprime / np.sqrt(np.dot(rprime, rprime)) + rpp = np.array([-a*np.sin(t), -a*np.cos(t), 0]) + n = rpp / np.dot(rpp, rpp) + b = np.cross(T, n) + dbdt = np.array([-2*np.sin(t), -2*np.cos(t), 0]) + tor = np.dot(dbdt, n) + + return tor -- cgit From bf773aca98a71c3d2cd5ff99aac2f2e853456178 Mon Sep 17 00:00:00 2001 From: Saarth Deshpande Date: Sun, 19 Jul 2020 17:12:03 +0530 Subject: final UPLOAD --- .../file5_torsion_intuition.py | 119 +++++++++++++ .../file6_fs2.py | 90 ++++++++++ .../file6_torsion_intuition.py | 119 ------------- .../file7_fs3.py | 194 +++++++++++++++++++++ 4 files changed, 403 insertions(+), 119 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_torsion_intuition.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_fs2.py delete mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py create mode 100644 FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file7_fs3.py (limited to 'FSF-2020/calculus-of-several-variables') diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_torsion_intuition.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_torsion_intuition.py new file mode 100644 index 0000000..31b9a85 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_torsion_intuition.py @@ -0,0 +1,119 @@ +from manimlib.imports import * + +class t(SpecialThreeDScene): + CONFIG = { + "axes_config": { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "z_min": -4, + "z_max": 4, + "x_axis_config": { + "tick_frequency": 100, + }, + "y_axis_config": { + "tick_frequency": 100, + }, + "z_axis_config": { + "tick_frequency": 100, + }, + "num_axis_pieces": 1, + } + } + def construct(self): + + text = TextMobject(r'Torsion can be intuitively \\ thought of as the measure \\ of "twisting" of a curve.').scale(0.7).shift(2.5*UP + 4.2*LEFT) + + + dot = Dot().rotate(PI/2) + f1 = ParametricFunction( + lambda t: np.array([ + 2*np.sin(TAU*t), + 2*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d1 = Dot(color = RED).next_to(f1.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.4*RIGHT) + t1 = self.get_torsion(2, 0.174) + t1 = "{:.2f}".format(t1) + t1 = TextMobject(fr'At the given point, $\tau = {t1}$').shift(3.5*DOWN).scale(0.7) + + f2 = ParametricFunction( + lambda t: np.array([ + 3*np.sin(TAU*t), + 3*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d2 = Dot(color = RED).next_to(f2.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.95*RIGHT) + t2 = self.get_torsion(3, 0.1765) + t2 = "{:.2f}".format(t2) + t2 = TextMobject(fr'At the given point, $\tau = {t2}$').shift(3.5*DOWN).scale(0.7) + + f3 = ParametricFunction( + lambda t: np.array([ + 4*np.sin(TAU*t), + 4*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d3 = Dot(color = RED).next_to(f3.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 3.45*RIGHT) + t3 = self.get_torsion(4, 0.179) + t3 = "{:.2f}".format(t3) + t3 = TextMobject(fr'At the given point, $\tau = {t3}$').shift(3.5*DOWN).scale(0.7) + + f4 = ParametricFunction( + lambda t: np.array([ + 1.5*np.sin(TAU*t), + 1.5*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d4 = Dot(color = RED).next_to(f4.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.215*UP + 2.128*RIGHT) + t4 = self.get_torsion(1.5, 0.173) + t4 = "{:.2f}".format(t4) + t4 = TextMobject(fr'At the given point, $\tau = {t4}$').shift(3.5*DOWN).scale(0.7) + + f5 = ParametricFunction( + lambda t: np.array([ + np.sin(TAU*t), + np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + + d5 = Dot(color = RED).next_to(f5.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.3*UP + 1.858*RIGHT) + t5 = self.get_torsion(1, 0.17) + t5 = "{:.2f}".format(t5) + t5 = TextMobject(fr'At the given point, $\tau = {t5}$').shift(3.5*DOWN).scale(0.7) + + axes = ThreeDAxes(**self.axes_config) + self.set_camera_orientation(phi = 60*DEGREES, theta=45*DEGREES) + self.add_fixed_in_frame_mobjects(t1, text) + self.play(FadeIn(VGroup(*[f1, d1, t1, axes, text]))) + self.wait(2) + self.add_fixed_in_frame_mobjects(t2) + self.play(ReplacementTransform(d1, d2), ReplacementTransform(f1, f2), ReplacementTransform(t1, t2)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t3) + self.play(ReplacementTransform(d2, d3), ReplacementTransform(f2, f3), ReplacementTransform(t2, t3)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t4) + self.play(ReplacementTransform(d3, d4), ReplacementTransform(f3, f4), ReplacementTransform(t3, t4)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t5) + self.play(ReplacementTransform(d4, d5), ReplacementTransform(f4, f5), ReplacementTransform(t4, t5)) + self.wait(2) + self.play(FadeOut(VGroup(*[d5, f5, t5, text, axes]))) + + def get_torsion(self, a, t): + rprime = np.array([a*np.cos(t), -a*np.sin(t), 2]) + T = rprime / np.sqrt(np.dot(rprime, rprime)) + rpp = np.array([-a*np.sin(t), -a*np.cos(t), 0]) + n = rpp / np.dot(rpp, rpp) + b = np.cross(T, n) + dbdt = np.array([-2*np.sin(t), -2*np.cos(t), 0]) + tor = np.dot(dbdt, n) + + return tor diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_fs2.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_fs2.py new file mode 100644 index 0000000..0c74685 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_fs2.py @@ -0,0 +1,90 @@ +from manimlib.imports import * + +class fs2(SpecialThreeDScene): + CONFIG = { + "x_min": -2, + "x_max": 2, + "y_min": -6, + "y_max": 6, + "graph_origin": ORIGIN + } + def construct(self): + axes = ThreeDAxes() + # text = TextMobject(r'$\frac{dB}{ds} = -\tau N$ \\ $\frac{dB}{ds}$ gives the direction of N, \\ while $\tau$ gives its magnitude.').scale(0.7).shift(3*UP + 3*LEFT) + self.set_camera_orientation(phi = 75*DEGREES, theta=135*DEGREES) + # self.move_camera(distance=0) + + # rprime = np.array([2*np.cos(t), -np.sin(t) - (2*np.sin(2*t)), 0]) + # t = rprime / np.sqrt(np.dot(rprime, rprime)) + # rpp = np.array([-2*np.sin(t), -np.cos(t) - (4*np.cos(2*t)), 0]) + # n = rpp / np.dot(rpp, rpp) + # b = np.cross(rprime, rpp) + text = TextMobject(r'$\frac{dB}{ds}$', r'$= -\tau$', r'$N$').shift(2*UP + 4*LEFT) + text.set_color_by_tex_to_color_map({ + r'$\frac{dB}{ds}$': YELLOW, + r'$N$': RED_C + }) + + dot = Dot().rotate(PI/2) + alpha = ValueTracker(0) + t = alpha.get_value + figure = ParametricFunction( + lambda t: np.array([ + np.sinh(t), + np.cosh(t), + 2*t + ]), t_min = -3, t_max = 3, color=BLUE + ).scale(0.5).move_to(ORIGIN) + vector_x = self.get_tangent_vector(t()%1, figure,scale=2) + vector_y = self.get_normal_vector(t(),figure,scale=2) + vector_x.add_updater( + lambda m: m.become( + self.get_tangent_vector(t()%1,figure,scale=2) + ) + ) + vector_y.add_updater( + lambda m: m.become( + self.get_normal_vector(t(),figure,scale=2) + ) + ) + dot.add_updater(lambda m: m.move_to(vector_y.get_start())) + + + + self.add_fixed_in_frame_mobjects(text) + self.play(FadeIn(figure), FadeIn(axes), FadeIn(text)) + self.begin_ambient_camera_rotation(rate = 0.1) + self.wait(1) + self.add(vector_x, vector_y,dot) + self.play(alpha.increment_value, 0.999, run_time=20, rate_func=rush_from) + self.wait(1) + self.remove(figure, vector_x, vector_y,dot) + self.play(FadeOut(figure), FadeOut(axes), FadeOut(text)) + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1): + t = proportion.copy() + coord_i = curve.point_from_proportion(proportion) + rprime = np.array([np.cosh(t), np.sinh(t), 2]) + T = rprime / np.sqrt(np.dot(rprime, rprime)) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + n = rpp / np.dot(rpp, rpp) + # b = (np.cross(T, n)[0] - 0.5, np.cross(T, n)[1], coord_i[2] + 1) + b = np.cross(T, n) + # coord_f = curve.point_from_proportion(proportion + dx) + coord_f = b + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * 1 + vector = Arrow(coord_i , coord_i + unit_vector, color = YELLOW, buff=0) + return vector + + def get_normal_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + t = proportion.copy()/7 + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + length = np.sqrt(np.dot(rpp, rpp)) + length = 1/(1 + np.exp(-length)) + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(length).scale(2) + unit_vector = reference_line.get_vector() * 0.7 + vector = Arrow(coord_i, coord_i + unit_vector, color = RED_C, buff=0) + return vector diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py deleted file mode 100644 index 31b9a85..0000000 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_torsion_intuition.py +++ /dev/null @@ -1,119 +0,0 @@ -from manimlib.imports import * - -class t(SpecialThreeDScene): - CONFIG = { - "axes_config": { - "x_min": -5, - "x_max": 5, - "y_min": -5, - "y_max": 5, - "z_min": -4, - "z_max": 4, - "x_axis_config": { - "tick_frequency": 100, - }, - "y_axis_config": { - "tick_frequency": 100, - }, - "z_axis_config": { - "tick_frequency": 100, - }, - "num_axis_pieces": 1, - } - } - def construct(self): - - text = TextMobject(r'Torsion can be intuitively \\ thought of as the measure \\ of "twisting" of a curve.').scale(0.7).shift(2.5*UP + 4.2*LEFT) - - - dot = Dot().rotate(PI/2) - f1 = ParametricFunction( - lambda t: np.array([ - 2*np.sin(TAU*t), - 2*np.cos(TAU*t), - 2*t - ]), t_min = -2, t_max = 2, color = BLUE - ).scale(0.5) - d1 = Dot(color = RED).next_to(f1.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.4*RIGHT) - t1 = self.get_torsion(2, 0.174) - t1 = "{:.2f}".format(t1) - t1 = TextMobject(fr'At the given point, $\tau = {t1}$').shift(3.5*DOWN).scale(0.7) - - f2 = ParametricFunction( - lambda t: np.array([ - 3*np.sin(TAU*t), - 3*np.cos(TAU*t), - 2*t - ]), t_min = -2, t_max = 2, color = BLUE - ).scale(0.5) - d2 = Dot(color = RED).next_to(f2.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.95*RIGHT) - t2 = self.get_torsion(3, 0.1765) - t2 = "{:.2f}".format(t2) - t2 = TextMobject(fr'At the given point, $\tau = {t2}$').shift(3.5*DOWN).scale(0.7) - - f3 = ParametricFunction( - lambda t: np.array([ - 4*np.sin(TAU*t), - 4*np.cos(TAU*t), - 2*t - ]), t_min = -2, t_max = 2, color = BLUE - ).scale(0.5) - d3 = Dot(color = RED).next_to(f3.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 3.45*RIGHT) - t3 = self.get_torsion(4, 0.179) - t3 = "{:.2f}".format(t3) - t3 = TextMobject(fr'At the given point, $\tau = {t3}$').shift(3.5*DOWN).scale(0.7) - - f4 = ParametricFunction( - lambda t: np.array([ - 1.5*np.sin(TAU*t), - 1.5*np.cos(TAU*t), - 2*t - ]), t_min = -2, t_max = 2, color = BLUE - ).scale(0.5) - d4 = Dot(color = RED).next_to(f4.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.215*UP + 2.128*RIGHT) - t4 = self.get_torsion(1.5, 0.173) - t4 = "{:.2f}".format(t4) - t4 = TextMobject(fr'At the given point, $\tau = {t4}$').shift(3.5*DOWN).scale(0.7) - - f5 = ParametricFunction( - lambda t: np.array([ - np.sin(TAU*t), - np.cos(TAU*t), - 2*t - ]), t_min = -2, t_max = 2, color = BLUE - ).scale(0.5) - - d5 = Dot(color = RED).next_to(f5.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.3*UP + 1.858*RIGHT) - t5 = self.get_torsion(1, 0.17) - t5 = "{:.2f}".format(t5) - t5 = TextMobject(fr'At the given point, $\tau = {t5}$').shift(3.5*DOWN).scale(0.7) - - axes = ThreeDAxes(**self.axes_config) - self.set_camera_orientation(phi = 60*DEGREES, theta=45*DEGREES) - self.add_fixed_in_frame_mobjects(t1, text) - self.play(FadeIn(VGroup(*[f1, d1, t1, axes, text]))) - self.wait(2) - self.add_fixed_in_frame_mobjects(t2) - self.play(ReplacementTransform(d1, d2), ReplacementTransform(f1, f2), ReplacementTransform(t1, t2)) - self.wait(2) - self.add_fixed_in_frame_mobjects(t3) - self.play(ReplacementTransform(d2, d3), ReplacementTransform(f2, f3), ReplacementTransform(t2, t3)) - self.wait(2) - self.add_fixed_in_frame_mobjects(t4) - self.play(ReplacementTransform(d3, d4), ReplacementTransform(f3, f4), ReplacementTransform(t3, t4)) - self.wait(2) - self.add_fixed_in_frame_mobjects(t5) - self.play(ReplacementTransform(d4, d5), ReplacementTransform(f4, f5), ReplacementTransform(t4, t5)) - self.wait(2) - self.play(FadeOut(VGroup(*[d5, f5, t5, text, axes]))) - - def get_torsion(self, a, t): - rprime = np.array([a*np.cos(t), -a*np.sin(t), 2]) - T = rprime / np.sqrt(np.dot(rprime, rprime)) - rpp = np.array([-a*np.sin(t), -a*np.cos(t), 0]) - n = rpp / np.dot(rpp, rpp) - b = np.cross(T, n) - dbdt = np.array([-2*np.sin(t), -2*np.cos(t), 0]) - tor = np.dot(dbdt, n) - - return tor diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file7_fs3.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file7_fs3.py new file mode 100644 index 0000000..698ca74 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file7_fs3.py @@ -0,0 +1,194 @@ +from manimlib.imports import * + +class f(SpecialThreeDScene): + CONFIG = { + "axes_config": { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "z_min": -4, + "z_max": 4, + "x_axis_config": { + "tick_frequency": 100, + }, + "y_axis_config": { + "tick_frequency": 100, + }, + "z_axis_config": { + "tick_frequency": 100, + }, + "num_axis_pieces": 1, + } + } + def construct(self): + axes = ThreeDAxes(**self.axes_config) + text = TextMobject(r'$r(t) = \left\langle\sinh{t}, \cosh{t}, 2t\right\rangle$').scale(0.7).shift(3*UP + 3*LEFT) + self.set_camera_orientation(phi = 75*DEGREES, theta=225*DEGREES) + + + + figure = ParametricFunction( + lambda t: np.array([ + np.sinh(t), + np.cosh(t), + 2*t + ]), t_min = -3, t_max = 3, color=ORANGE + ).scale(0.5).move_to(ORIGIN) + + dot = Dot(color=RED) + alpha = ValueTracker(0) + t = alpha.get_value + + vector_x = self.get_binormal_vector(t()%1, figure,scale=2) + vector_y = self.get_normal_vector(t(),figure,scale=2) + vector_z = self.get_tangent_vector(t(), figure, scale=2) + + vector_x.add_updater( + lambda m: m.become( + self.get_binormal_vector(t()%1,figure,scale=2) + ) + ) + vector_y.add_updater( + lambda m: m.become( + self.get_normal_vector(t(),figure,scale=2) + ) + ) + vector_z.add_updater( + lambda m: m.become( + self.get_tangent_vector(t(),figure,scale=2) + ) + ) + dot.add_updater( + lambda m: m.move_to(vector_x.get_start()) + ) + def curvature(t): + r = np.array([np.sinh(t), np.cosh(t), 2*t]) + rp = np.array([np.cosh(t), np.sinh(t), 2]) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + cp = np.cross(rp, rpp) + k = cp / (np.dot(rp, rp)**1.5) + return abs(k[0]) + + def torsion(t): + r = np.array([np.sinh(t), np.cosh(t), 2*t]) + rp = np.array([np.cosh(t), np.sinh(t), 2]) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + n = rpp / np.dot(rpp, rpp) + dbdt = np.array([2*np.sinh(t), 2*np.cosh(t), 0]) + tor = np.dot(dbdt, n) + return tor + + + + k = curvature(0.3) + k = "{:.2f}".format(k) + tor = torsion(0.3) + tor = "{:.2f}".format(tor) + kt1 = TextMobject(rf'At the given point, \\ $\kappa =$ {k} \\').scale(0.7).shift(3*UP + 4*RIGHT) + kt2 = TextMobject('$\implies \kappa$',r'$T$',r' is scaled as:').scale(0.7).next_to(kt1, DOWN, buff=0.1) + kt2.set_color_by_tex_to_color_map({ + '$T$': YELLOW + }) + tbt1 = TextMobject(rf'At the given point, \\ $\tau =$ {tor} \\').scale(0.7).shift(3*UP + 4*RIGHT) + tbt2 = TextMobject(r'$\implies \tau$',r'$B$',r' is scaled as:').scale(0.7).next_to(tbt1, DOWN, buff=0.1) + tbt2.set_color_by_tex_to_color_map({ + '$B$': GREEN_E + }) + ft = TextMobject(r'$\frac{dN}{ds}$',r'$ = -\kappa$',r'$T$', r'$ + \tau$',r'$B$ \\', r'and is given as:').scale(0.7).shift(3*UP + 4*RIGHT) + ft.set_color_by_tex_to_color_map({ + r'$\frac{dN}{ds}$': GREEN_SCREEN, + '$T$': YELLOW, + r'$B$ \\': GREEN_E + }) + + self.add_fixed_in_frame_mobjects(text) + self.play(FadeIn(figure), FadeIn(axes), FadeIn(text)) + # self.begin_ambient_camera_rotation(rate = 0.13) + self.wait(1) + self.add(vector_x, vector_y,vector_z,dot) + self.play(alpha.increment_value, 0.3, run_time=10, rate_func=rush_from) + self.wait(1) + # self.stop_ambient_camera_rotation() + # self.move_camera(phi = 75*DEGREES, theta=225*DEGREES) + square = Rectangle(width=3.2, fill_color=WHITE, fill_opacity=0.3, color=RED_C).rotate(40*DEGREES).shift(0.8*DOWN+1.2*RIGHT) + mat = [[0.7, 0.3], [1.0, -0.7]] + square = square.apply_matrix(mat).rotate(17*DEGREES).shift(2.1*DOWN+RIGHT) + tl, nl, bl = TextMobject(r'$T$', color=YELLOW).shift(2.8*RIGHT+0.5*DOWN), TextMobject(r'$N$', color=BLUE).shift(RIGHT), TextMobject(r'$B$', color=GREEN_E).shift(0.6*LEFT+0.5*DOWN) + self.add_fixed_in_frame_mobjects(tl, nl, bl) + self.play(FadeIn(VGroup(*[tl, nl, bl]))) + self.wait(3) + self.add_fixed_in_frame_mobjects(square) + self.play(FadeIn(square), FadeOut(VGroup(*[tl, nl, bl]))) + self.wait(2) + self.add_fixed_in_frame_mobjects(kt1) + self.play(FadeIn(kt1)) + self.wait(2) + self.add_fixed_in_frame_mobjects(kt2) + self.play(FadeIn(kt2)) + self.wait(2) + kt = self.get_tangent_vector(0.3, figure, scale = -4*float(k)) + tb = self.get_binormal_vector(0.3, figure, scale = 2*float(tor)) + self.play( + ReplacementTransform(vector_z, kt) + ) + self.wait(3) + self.add_fixed_in_frame_mobjects(tbt1) + self.play(FadeOut(VGroup(*[kt1, kt2])), FadeIn(tbt1)) + self.wait(2) + self.add_fixed_in_frame_mobjects(tbt2) + self.play(FadeIn(tbt2)) + self.wait(2) + self.play( + ReplacementTransform(vector_x, tb) + ) + self.wait(2) + self.add_fixed_in_frame_mobjects(ft) + self.play(FadeOut(VGroup(*[tbt1, tbt2])), FadeIn(ft)) + self.wait(2) + dnds = Arrow(dot.get_center() + np.array([-0.1,-0.25,0]), np.array([-4,-1,2]), color=GREEN_SCREEN) + dndsl = TextMobject(r'$\frac{dN}{ds}$', color=GREEN_SCREEN).shift(2.5*LEFT + 1.2*UP) + self.add_fixed_in_frame_mobjects(dndsl) + self.play(FadeIn(dnds), FadeIn(dndsl)) + self.wait(5) + self.play(FadeOut(VGroup(*[square, dot,vector_y, dnds, dndsl, text, ft, tb, kt]))) + self.play(FadeOut(figure), FadeOut(axes)) + + + def get_binormal_vector(self, proportion, curve, dx=0.001, scale=1): + t = proportion + coord_i = curve.point_from_proportion(proportion) + rprime = np.array([np.cosh(t), np.sinh(t), 2]) + T = rprime / np.sqrt(np.dot(rprime, rprime)) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + n = rpp / np.dot(rpp, rpp) + # b = (np.cross(T, n)[0] - 0.5, np.cross(T, n)[1], coord_i[2] + 1) + b = np.cross(T, n) + # coord_f = curve.point_from_proportion(proportion + dx) + coord_f = b + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i , coord_i + unit_vector, color = GREEN_E, buff=0) + return vector + + def get_normal_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + t = proportion.copy()/7 + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + length = np.sqrt(np.dot(rpp, rpp)) + length = 1/(1 + np.exp(-length)) + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(length).scale(2) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i, coord_i + unit_vector, color = BLUE, buff=0) + return vector + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + reference_line = Line(coord_i,coord_f).scale(2) + if scale < 0: + reference_line = Line(coord_i,coord_f).scale(2).rotate(360*DEGREES) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i, coord_i + unit_vector, color = YELLOW, buff=0) + return vector -- cgit