diff options
author | Saarth Deshpande | 2020-07-04 02:13:27 +0530 |
---|---|---|
committer | Saarth Deshpande | 2020-07-04 02:13:27 +0530 |
commit | 05080cd0751a9ebd7acf9c94790461038aa9a069 (patch) | |
tree | 028ba24d4d470b9e9132235c861a6030ac1fa625 | |
parent | 8096534204aeb06ea8e4b7a25c5bf4f7f1d52ffb (diff) | |
download | FSF-mathematics-python-code-archive-05080cd0751a9ebd7acf9c94790461038aa9a069.tar.gz FSF-mathematics-python-code-archive-05080cd0751a9ebd7acf9c94790461038aa9a069.tar.bz2 FSF-mathematics-python-code-archive-05080cd0751a9ebd7acf9c94790461038aa9a069.zip |
tnb, curvature interpretation
4 files changed, 233 insertions, 344 deletions
diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py index 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]))) |