diff options
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem')
8 files changed, 792 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file1_ftc-analogue.gif b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file1_ftc-analogue.gif Binary files differnew file mode 100644 index 0000000..1101a96 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file1_ftc-analogue.gif diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file1_ftc-analogue.py b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file1_ftc-analogue.py new file mode 100644 index 0000000..222663b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file1_ftc-analogue.py @@ -0,0 +1,265 @@ +from manimlib.imports import * + + +def vector_field_func(coordinate): + x,y = coordinate[:2] + return np.array([ + x, + y, + 0 + ]) +def curl(coordinate): + x,y = coordinate[:2] + U = (x**2 + y**2) + return np.array([ + -y/(x**2 + y**2), + x/(x**2 + y**2), + 0 + ]) + + + + + +class GreensVisual(Scene): + + def construct(self): + axes_config = {"x_min": -6, + "x_max": 6, + "y_min": -6, + "y_max": 6, + "z_axis_config": {}, + "z_min": -1, + "z_max": 1, + "z_normal": DOWN, + "light_source": 9 * DOWN + 7 * LEFT + 10 * OUT, + "number_line_config": { + "include_tip": False, + }, + } + + axes = Axes(**axes_config) + + field = VectorField(vector_field_func).fade(0.5) + self.add(field) + + title = TexMobject(r"\textit{According to Green's Theorem, }").shift(3*UP) + + eq1 = TexMobject(r"\int_{C} \vec F . dr = \int \int_{D} \nabla \times \vec F dA").shift(3*DOWN) + eq5 = TexMobject(r"\int_{C} \vec F . dr = \int \int_{D} \nabla \times \vec F dA").shift(3*DOWN) + + generalisation = TexMobject() + + eq2 = TexMobject(r"\int_{C} \vec F . dr = \int_{C_1} \vec F . dr + \int_{C_{2}} \vec F . dr").shift(3*DOWN) + eq3 = TexMobject(r"\int_{C} \vec F . dr = \int_{C_{1}} \vec F . dr + \int_{C_{2}} \vec F . dr + \int_{C_{3}} \vec F . dr + \int_{C_{4}} \vec F . dr...").shift(3*DOWN) + eq4 = TexMobject(r"\int_{C_{r}} \vec F dr \approx \int\int_{D} \nabla \times \vec F dA").shift(3*DOWN) + eq = TexMobject(r"\int_{C_{r}} \textit{macroscopic curl} = \int\int_{D} \text{sum of all microscopic curls}").shift(3*UP) + + text_1 = TexMobject(r"\textit{Split C into 2 parts and calculate curl of each one of the smaller regions seperately}").shift(3*UP) + #text_2 = TexMobject(r"\textit{}").shift(3*UP) + text_3 = TexMobject(r"\textit{By splitting C into n segments, the area of each region approaches the limit 0}", r"\textit{The macroscopic circulation along the curve }", r"\textit{is equivalent to the sum of microscopic circulation of all these small regions }") + text_3[0].move_to(3.8*UP) + text_3[1].set_color(YELLOW_E).next_to(text_3[0], DOWN, buff = SMALL_BUFF) + text_3[2].set_color(BLUE_E).next_to(text_3[1], DOWN, buff = SMALL_BUFF) + + + + curl_rep_1 = StreamLines( + curl, + virtual_time=4, + min_magnitude=0, + max_magnitude=2, + dt = 0.1, + x_min = -0.5, x_max = 0.5, y_min = -0.5, y_max = 0.5, + ).set_color_by_gradient([BLUE_E, TEAL, WHITE]) + flow_1 = AnimatedStreamLines( + curl_rep_1, + line_anim_class=ShowPassingFlashWithThinningStrokeWidth + ) + + static = VMobject() + for p in range(0, 8, 4): + curl_rep_n = [*StreamLines( + curl, + virtual_time=2, + min_magnitude=0, + max_magnitude=1, + dt = 0.1, + x_min = -0.5, x_max = 0.5, y_min = -0.5, y_max = 0.5, + ).scale(0.5).move_to(np.array([-2+p, 0,0]))] + static.add(*curl_rep_n) + static_1 = VMobject() + for p in range(-3, 4, 2): + curl_rep_1 = [*StreamLines( + curl, + virtual_time=2, + min_magnitude=0, + max_magnitude=1, + dt = 0.1, + x_min = -0.5, x_max = 0.5, y_min = -0.5, y_max = 0.5, + ).scale(0.25).move_to(np.array([p, 0.6,0]))] + static_1.add(*curl_rep_1) + + static_2 = VMobject() + for p in range(-3, 4, 2): + curl_rep_2 = [*StreamLines( + curl, + virtual_time=2, + min_magnitude=0, + max_magnitude=1, + dt = 0.1, + x_min = -0.5, x_max = 0.5, y_min = -0.5, y_max = 0.5, + ).scale(0.25).move_to(np.array([p, -0.6,0]))] + static_2.add(*curl_rep_2) + + + + surface_6 = ParametricSurface( + self.surface, + u_min=-3, + u_max=3, + v_min=-3, + v_max=3, + fill_color=BLACK, + checkerboard_colors=[BLACK, BLACK], + stroke_color=BLUE_E, + resolution = [64,64] + ).set_fill(opacity=0.2).scale(1.5) + + boundary = ParametricSurface( + self.surface, + u_min=-3, + u_max=3, + v_min=-3, + v_max=3, + fill_color=BLACK, + checkerboard_colors=[BLACK, BLACK], + stroke_color=YELLOW_E, + resolution = [2,1] + ).set_fill(opacity=0).scale(1.75) + + + + + g1 = VGroup(surface_1, c) + g2 = VGroup( c1, c2, text_1) + g3 = VGroup(c1a, c2a, c3a, c4a) + + tr = Ellipse(width = 9, height = 3) + line = Line(tr.get_center()+1.5*UP, tr.get_center()+1.5*DOWN) + b = VMobject(stroke_color = "#F4EDED") + b.set_points_smoothly([tr.get_center()+1.5*UP, np.array([-2.25, 1.26, 0]), tr.get_center()+4.5*LEFT, np.array([-2.25, -1.26, 0]), tr.get_center()+1.5*DOWN]) + + + self.add(title) + self.play(ShowCreation(g1), ShowCreation(eq1)) + self.wait(3) + self.remove(flow_1) + self.play(ShowCreation(surface_2), ReplacementTransform(eq1, eq2)) + self.remove(g1) + self.wait() + self.play(ReplacementTransform(surface_2, surface_3), ReplacementTransform(eq2, eq3)) + self.wait() + self.wait() + self.play(FadeOut(surface_3), ShowCreation(surface_4), ReplacementTransform(eq3, eq4), ReplacementTransform(title, eq)) + self.play(FadeOut(surface_4), ShowCreation(surface_5)) + self.play(FadeOut(surface_5), ShowCreation(surface_6)) + self.wait() + #self.add(tr, line) + self.wait() + grd = ScreenGrid() + + g = ParametricFunction(func, t_min = 0, t_max = 2*PI).scale(1.5) + self.add(grd, g) + self.wait() + + +def circ(coordinate): + x,y = coordinate[:2] + for x in range(0, -5) and y in range(-1,1): + cr = Ellipse() + return cr + +def func(t): + return np.array([ + np.sin(t), + np.cos(t), + 0]) + +def surf(t,u): + return np.array([ + u*np.sin(t), + np.cos(t), + 0]) + +class Analogy(GraphScene): + CONFIG = { + "x_min": -1, + "x_max": 4, + "y_min": 0, + "y_max": 2, + "y_tick_frequency": 2.5, + "n_rect_iterations": 6, + "default_right_x": 3, + } + + def construct(self): + + + ftc = TexMobject(r"\int_a^b f'(x) \ dx", r" = f(b) - f(a)").shift(3*UP).set_color("#F9DB6D").scale(0.7) + greens = TexMobject(r"\int \int_{R} curl \left(\vec F \right) \ dxdy", r" = \int_{C} \vec F \ dr").shift(3*UP).set_color("#F9DB6D").scale(0.7) + ftc[0].set_color("#36827F") + greens[1].set_color("#36827F") + + + two_to_one = TexMobject(r"\textit{2D region} \to", r"\textit{1D curve}").shift(3.6*DOWN).scale(0.7).set_color("#F9DB6D") + one_to_zero = TexMobject(r"\textit{1D curve}", r" \to \textit{0D points}").shift(3.6*DOWN).set_color("#F9DB6D").scale(0.7) + two_to_one[1].set_color("#36827F") + one_to_zero[0].set_color("#36827F") + greens_title = TexMobject(r"\textit{Green's Theorem}").scale(0.8).next_to(two_to_one, UP, buff = SMALL_BUFF).set_color("#F4EDED") + ftc_title = TexMobject(r"\textit{Fundamental Theorem of Calculus}").scale(0.8).next_to(two_to_one, UP, buff = SMALL_BUFF).set_color("#F4EDED") + + surf= VMobject(fill_color = "#ED6A5A", stroke_color = "#ED6A5A", fill_opacity = 0.6) + surf.set_points_smoothly([np.array([-2, 1.8,0]),np.array([-1.6, 0.5,0]),np.array([-3.2, -1.2,0]),np.array([2.6, -1.5,0]),np.array([1, 0,0]),np.array([3.5,2.3, 0]), np.array([-2,1.8, 0])]) + dot = Dot(np.array([-2,1.8, 0])).set_color("#F4EDED") + boundary = VMobject(stroke_color = "#F4EDED") + boundary.set_points_smoothly([np.array([-2, 1.8,0]),np.array([-1.6, 0.5,0]),np.array([-3.2, -1.2,0]),np.array([2.6, -1.5,0]),np.array([1, 0,0]),np.array([3.5,2.3, 0]), np.array([-2,1.8, 0])]) + c = TexMobject(r"C").next_to(surf,RIGHT+UP).set_color("#F4EDED") + r = TexMobject(r"R").move_to(np.array([-0.2, 0.6, 0])).set_color("#F4EDED") + + self.play(ShowCreation(surf), ShowCreation(r)) + self.wait(2) + self.play(ShowCreation(boundary), MoveAlongPath(dot, boundary), Write(c), Write(greens),Write(greens_title), run_time= 1.5) + self.wait(2) + self.play(ReplacementTransform(surf, boundary), FadeOut(r), Write(two_to_one), FadeOut(dot)) + self.wait(2) + + self.setup_axes() + + grapher = self.get_graph(self.funk) + grapher.set_color("#E94F37") + l1 = self.get_vertical_line_to_graph(1, grapher, color = "#F4EDED") + l2 =self.get_vertical_line_to_graph(3, grapher, color = "#F4EDED") + label_coord_1 = self.input_to_graph_point(1,grapher) + label_coord_2 = self.input_to_graph_point(3,grapher) + + + a = TexMobject(r"a").next_to(label_coord_1,RIGHT+UP).set_color("#F4EDED") + b = TexMobject(r"b").next_to(label_coord_2,RIGHT+UP).set_color("#F4EDED") + + + + + + point_a = Dot(label_coord_1).set_color("#827081") + point_b = Dot(label_coord_2).set_color("#827081") + + + self.play(ReplacementTransform(boundary, grapher), FadeOut(c), FadeIn(a), FadeIn(b), FadeIn(point_a), FadeIn(point_b), ReplacementTransform(greens, ftc), ReplacementTransform(greens_title, ftc_title)) + self.wait(2) + self.play(Uncreate(grapher), ReplacementTransform(two_to_one, one_to_zero)) + self.wait(2) + + + def funk(self,x): + return 0.2*(x-2)**2 +1
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file2_line-int.gif b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file2_line-int.gif Binary files differnew file mode 100644 index 0000000..22d0509 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file2_line-int.gif diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file2_line-int.py b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file2_line-int.py new file mode 100644 index 0000000..704acf7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file2_line-int.py @@ -0,0 +1,132 @@ +from manimlib.imports import * + +def field_func(coordinate): + x,y = coordinate[:2] + return np.array([ + -x, + -y, + 0 + ]) + + +class LineIntegral(MovingCameraScene, Scene): + def setup(self): + MovingCameraScene.setup(self) + Scene.setup(self) + + def get_pending(self,path,proportion,dx=0.01): + if proportion < 1: + coord_i = path.point_from_proportion(proportion) + coord_f = path.point_from_proportion(proportion+dx) + else: + coord_i = path.point_from_proportion(proportion-dx) + coord_f = path.point_from_proportion(proportion) + line = Line(coord_i,coord_f) + angle = line.get_angle() + return angle + + def construct(self): + + + # all the text + vec_f = TexMobject(r"\vec F",r" \textit{ is a vector field defined on the plane}").set_color("#EDF2EF") + c = TexMobject(r"C",r" \textit{ is a curve on the plane, oriented counter-clockwise.}").set_color("#EDF2EF") + dr = TexMobject(r"\vec dr", r"\textit{ gives the direction as we move along C}").set_color("#EDF2EF") + + intg = TexMobject(r"\oint \vec F \cdot \vec dr", r"\textit{ gives the rotation along the curve}").shift(2.5*DOWN).scale(0.7).set_color("#EDF2EF") + text = VGroup(vec_f, c, dr).scale(0.6).set_stroke(width = 1.5) + text.arrange(DOWN, buff = 0.2) + text.shift(3.2*DOWN) + + vec_f[0].set_color("#D1D646") + dr[0].set_color("#D1D646") + intg[0].set_color("#D1D646") + + + + + self.camera_frame.save_state() + vec_f_sym = TexMobject(r"\vec F") + c_sym = TexMobject(r"C").move_to(4.8*RIGHT+1.3*UP) + dr_sym = TexMobject(r"\vec dr").next_to(vec_f_sym, DOWN, buff = SMALL_BUFF) + dp_sym = TexMobject(r"\vec F \cdot \vec dr") + intg_sym = TexMobject(r"\oint \vec F \cdot \vec dr") + + symbols = VGroup(vec_f_sym, dr_sym, dp_sym, intg_sym).shift(3*UP).set_color("#D1D646") + + + + + vector_field = VectorField(field_func, x_min = -15, x_max = 15, y_min = -15, y_max = 15).fade(0.5) + boundary = Ellipse(width = 9, height = 3).set_color("#32908F") + b2 = Ellipse(width = 9, height = 3).set_color(WHITE) + + start_angle = self.get_pending(boundary, 0) + + pointer = Triangle(fill_opacity = 1).set_height(0.25).set_color(WHITE) + pointer.set_fill(WHITE) + pointer.move_to(boundary.get_start()) + pointer.rotate(- PI / 2) + pointer.save_state() + pointer.rotate(start_angle, about_point=pointer.get_center()) + dp_sym_1 = TexMobject(r"\vec F \cdot \vec dr").next_to(pointer, RIGHT, buff = SMALL_BUFF).scale(0.5).set_color("#D1D646").add_background_rectangle() + intg_sym_1 = TexMobject(r"\oint \vec F \cdot \vec dr").next_to(pointer, RIGHT, buff = SMALL_BUFF).scale(0.5).set_color("#75485E").add_background_rectangle() + dp = TexMobject(r"\vec F \cdot \vec dr \textit{ measures whether } \vec F \textit{ and } \vec dr", r" \textit{ are oriented the same way }").next_to(dp_sym_1, DOWN, buff = SMALL_BUFF).scale(0.3).set_color("#EDF2EF") + dp[1].next_to(dp[0], DOWN, buff = SMALL_BUFF) + + + # groups according to animation + #one = VGroup( vec_f, vec_f_sym) + #two = VGroup(boundary, c_sym) + #three = VGroup(dr_sym, pointer) + #four = VGroup(dp, dp_sym) #this is when to zoom in + #five = VGroup(intg, intg_sym) + + delete = VGroup(vec_f, vec_f_sym, c, dr, dr_sym) + + + self.play(ShowCreation(vec_f), ShowCreation(vec_f_sym)) + self.wait() + self.play(ShowCreation(vector_field), Indicate(vec_f_sym)) + self.wait(2) + self.play(ShowCreation(c)) + self.wait() + self.play(ShowCreation(boundary), ShowCreation(c_sym), Indicate(c)) + self.wait(2) + self.play(ShowCreation(dr)) + self.wait(2) + self.play(ShowCreation(dr_sym), Indicate(dr), ShowCreation(pointer)) + + self.play(FadeOut(delete)) + self.play( + self.camera_frame.scale,.25, + self.camera_frame.move_to,pointer + ) + self.play(ShowCreation(dp_sym_1), ShowCreation(dp[0]), ShowCreation(dp[1])) + self.add(dp_sym) + self.wait(3) + self.play(Restore(self.camera_frame)) + self.remove(dp[0], dp[1], dp_sym_1) + self.wait() + self.add(boundary, pointer, self.camera_frame) + def update_rotate_move(mob,alpha): + pointer.restore() + + angle = self.get_pending(boundary,alpha) + + pointer.move_to(boundary.point_from_proportion(alpha)) + pointer.rotate(angle, about_point=pointer.get_center()) + + + + self.play( + #self.camera_frame.scale,.25, + UpdateFromAlphaFunc(pointer,update_rotate_move), + run_time=3, + ) + self.play(Write(b2)) + self.play(ReplacementTransform(dp_sym, intg_sym), ShowCreation(intg)) + self.play(ReplacementTransform(b2, intg_sym)) + self.play(Indicate(intg_sym)) + self.wait(2) + diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file3_line-int-sum.gif b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file3_line-int-sum.gif Binary files differnew file mode 100644 index 0000000..bedfd4c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file3_line-int-sum.gif diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file3_line-int-sum.py b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file3_line-int-sum.py new file mode 100644 index 0000000..c5280e1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file3_line-int-sum.py @@ -0,0 +1,211 @@ +from manimlib.imports import * + +def field_func(coordinate): + x,y = coordinate[:2] + return np.array([ + -x, + -y, + 0 + ]) + + +class LineIntegral(MovingCameraScene, Scene): + def setup(self): + MovingCameraScene.setup(self) + Scene.setup(self) + + def get_pending(self,path,proportion,dx=0.01): + if proportion < 1: + coord_i = path.point_from_proportion(proportion) + coord_f = path.point_from_proportion(proportion+dx) + else: + coord_i = path.point_from_proportion(proportion-dx) + coord_f = path.point_from_proportion(proportion) + line = Line(coord_i,coord_f) + angle = line.get_angle() + return angle + + def construct(self): + axes_config = {"x_min": -6, + "x_max": 6, + "y_min": -6, + "y_max": 6, + "z_axis_config": {}, + "z_min": -1, + "z_max": 1, + "z_normal": DOWN, + "light_source": 9 * DOWN + 7 * LEFT + 10 * OUT, + "number_line_config": { + "include_tip": False, + }, + } + + axes = Axes(**axes_config) + c_sym = TexMobject(r"C").move_to(4.8*RIGHT+1.3*UP) + + + final_eq = TexMobject(r"\oint_{C} \vec F \cdot \vec dr", r" = \sum_{i = 1}^{n} \oint_{C_{i}} \vec F \cdot \vec dr ").shift(3*DOWN).set_color("#EDF2EF").scale(1.5) + final_eq[0].set_color("#D1D646") + + text = TexMobject(r"\oint_{C} \vec F . dr",r" = \oint_{C_{1}} \vec F . dr ",r"+ \oint_{C_{2}} \vec F . dr",r" + \oint_{C_{3}} \vec F . dr + \oint_{C_{4}} \vec F . dr + ...", r" + \oint_{C_n} \vec F \cdot \vec dr ").shift(3*DOWN).set_color("#EDF2EF").scale(0.7) + text[0].set_color("#D1D646") + + vector_field = VectorField(field_func, x_min = -15, x_max = 15, y_min = -15, y_max = 15).fade(0.5) + boundary = Ellipse(width = 9, height = 3).set_color("#32908F") + start_angle = self.get_pending(boundary, 0) + + pointer = Triangle(fill_opacity = 1).set_height(0.25).set_color(YELLOW_E) + pointer.set_fill(YELLOW_E) + pointer.move_to(boundary.get_start()) + pointer.rotate(- PI / 2) + pointer.save_state() + pointer.rotate(start_angle, about_point=pointer.get_center()) + + split_1 = Line(boundary.get_center()+1.5*UP, boundary.get_center()+1.5*DOWN).set_color("#32908F") + split_2 = Line(boundary.get_center()+4.5*LEFT, boundary.get_center()+4.5*RIGHT).set_color("#32908F") + + surface_3 = ParametricSurface( + self.surface, + u_min=-3, + u_max=3, + v_min=-3, + v_max=3, + fill_color=BLACK, + checkerboard_colors=[BLACK, BLACK], + stroke_color="#32908F", + stroke_width = 1.5, + resolution = [4,4] + ).set_fill(opacity=0.2).scale(1.5).set_stroke(width = 1.5) + + surface_4 = ParametricSurface( + self.surface, + u_min=-3, + u_max=3, + v_min=-3, + v_max=3, + fill_color=BLACK, + checkerboard_colors=[BLACK, BLACK], + stroke_color="#32908F", + stroke_width = 1.5, + resolution = [16,16] + ).set_fill(opacity=0.2).scale(1.5).set_stroke(width = 1.5) + + surface_5 = ParametricSurface( + self.surface, + u_min=-3, + u_max=3, + v_min=-3, + v_max=3, + fill_color=BLACK, + checkerboard_colors=[BLACK, BLACK], + stroke_color="#32908F", + stroke_width = 1.5, + resolution = [32,32] + ).set_fill(opacity=0.2).scale(1.5).set_stroke(width = 1.5) + surface_6 = ParametricSurface( + self.surface, + u_min=-3, + u_max=3, + v_min=-3, + v_max=3, + fill_color=BLACK, + checkerboard_colors=[BLACK, BLACK], + stroke_color="#32908F", + stroke_width = 1.5, + resolution = [64,64] + ).set_fill(opacity=0.2).scale(1.5).set_stroke(width = 1.5) + + dot = Dot() + dot_1 = Dot() + dot_2 = Dot() + + + pointer = Triangle(fill_opacity = 1).set_height(0.25).set_color("#75485E") + pointer.set_fill("#75485E") + pointer.move_to(boundary.get_start()) + pointer.rotate(- PI / 2) + pointer.save_state() + pointer.rotate(start_angle, about_point=pointer.get_center()) + + pointer_b2 = Triangle(fill_opacity = 1).set_height(0.25).set_color(YELLOW_E) + pointer_b2.set_fill(YELLOW_E) + pointer_b2.move_to(boundary.get_start()) + pointer_b2.rotate(- PI / 2) + pointer_b2.save_state() + pointer_b2.rotate(start_angle, about_point=pointer_b2.get_center()) + + + # labels + labels_1 = VGroup( TexMobject(r"C_{1}").move_to(np.array([0, 3, 0])), + TexMobject(r"C_{2}").move_to(np.array([0, -3, 0]))).scale(0.7) + labels_2 = VGroup( TexMobject(r"C_{1}").move_to(np.array([-2.25, 2.5, 0])), + TexMobject(r"C_{2}").move_to(np.array([-2.25, -2.5, 0])), + TexMobject(r"C_{3}").move_to(np.array([2.25, -2.5, 0])), + TexMobject(r"C_{4}").move_to(np.array([2.25, 2.5, 0]))).scale(0.7) + + og = VGroup(boundary, split_1, split_2, labels_1, labels_2) + + + self.add(vector_field, boundary, pointer, text[0], c_sym) + def update_rotate_move(mob,alpha): + pointer.restore() + + angle = self.get_pending(boundary,alpha) + + pointer.move_to(boundary.point_from_proportion(alpha)) + pointer.rotate(angle, about_point=pointer.get_center()) + + self.play( + UpdateFromAlphaFunc(pointer,update_rotate_move), + run_time=3, + ) + self.wait() + self.play(Indicate(text[0])) + self.wait(2) + self.play(ShowCreation(text[1]), FadeIn(split_2), ShowCreation(text[2]), ShowCreation(labels_1), FadeOut(pointer), FadeOut(c_sym)) + self.play(Indicate(text[1]), Indicate(text[2])) + self.wait(2) + self.play(FadeIn(split_1), ShowCreation(text[3]), ReplacementTransform(labels_1, labels_2)) + self.play(Indicate(text[1]), Indicate(text[2]), Indicate(text[3])) + self.wait(2) + self.play(FadeOut(og), ShowCreation(surface_3)) + self.play(FadeOut(surface_3), ShowCreation(surface_4)) + self.play(FadeOut(surface_4), ShowCreation(surface_5)) + self.play(FadeOut(surface_5), ShowCreation(surface_6), ShowCreation(text[4])) + self.wait(2) + self.play(ReplacementTransform(text, final_eq)) + self.wait() + self.play(Indicate(final_eq)) + self.wait() + + + + + + + + + + + + + + + + + + + + + + + + @staticmethod + def surface(t, v): + return np.array([ + v*np.sin(t), + np.cos(t), + 0 + ]) + + diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file4_theorem-proof.gif b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file4_theorem-proof.gif Binary files differnew file mode 100644 index 0000000..ead9fe5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file4_theorem-proof.gif diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file4_theorem-proof.py b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file4_theorem-proof.py new file mode 100644 index 0000000..b038bd9 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Greens Theorem/GreensTheorem_file4_theorem-proof.py @@ -0,0 +1,184 @@ +from manimlib.imports import * + +def field_func(coordinate): + x,y = coordinate[:2] + return np.array([ + -x, + -y, + 0 + ]) + +def curl(coordinate): + x,y = coordinate[:2] + U = (x**2 + y**2) + return np.array([ + -y/(x**2 + y**2), + x/(x**2 + y**2), + 0 + ]) + + +class LineIntegral(ZoomedScene, Scene): + def setup(self): + ZoomedScene.setup(self) + Scene.setup(self) + + def get_pending(self,path,proportion,dx=0.01): + if proportion < 1: + coord_i = path.point_from_proportion(proportion) + coord_f = path.point_from_proportion(proportion+dx) + else: + coord_i = path.point_from_proportion(proportion-dx) + coord_f = path.point_from_proportion(proportion) + line = Line(coord_i,coord_f) + angle = line.get_angle() + return angle + + def construct(self): + CONFIG = { + "zoom_factor": 0.3, + "zoomed_display_height": 1, + "zoomed_display_width": 6, + "image_frame_stroke_width": 20, + "zoomed_camera_config": { + "default_frame_stroke_width": 3, + }, + } + + + axes_config = {"x_min": -6, + "x_max": 6, + "y_min": -6, + "y_max": 6, + "z_axis_config": {}, + "z_min": -1, + "z_max": 1, + "z_normal": DOWN, + "light_source": 9 * DOWN + 7 * LEFT + 10 * OUT, + "number_line_config": { + "include_tip": False, + }, + } + + axes = Axes(**axes_config) + surface_a = ParametricSurface( + self.surface, + u_min=-3, + u_max=3, + v_min=-3, + v_max=3, + fill_color=BLACK, + checkerboard_colors=[BLACK, BLACK], + stroke_color=BLUE_E, + stroke_width = 1.5, + resolution = [64,64] + ).set_fill(opacity=0.2).scale(1.5).set_stroke(width = 1.5) + vector_field = VectorField(field_func) + + dot = Dot().scale(0.5).shift(0.49*LEFT+0.039*UP) + dot_show = Dot().scale(0.05).move_to(dot.get_center()) + + zoomed_camera = self.zoomed_camera + zoomed_display = self.zoomed_display + frame = zoomed_camera.frame + zoomed_display_frame = zoomed_display.display_frame + + frame.move_to(dot) + frame.scale(0.75) + + box = Square(fill_color= BLUE_E, fill_opacity = 0.8).scale(0.07).move_to(dot.get_center()).flip() + + label_box = TexMobject(r"D_i").scale(0.05).next_to(box, DOWN, buff = 0.05) + + label = TexMobject(r"x_i, y_i").scale(0.06).next_to(dot_show, DOWN, buff = 0.05) + + start_angle = self.get_pending(box, 0) + + pointer = Triangle(fill_opacity = 1).set_height(0.03).set_color(YELLOW_E) + pointer.set_fill(YELLOW_E) + pointer.move_to(box.get_start()) + pointer.rotate(- PI / 2) + pointer.save_state() + pointer.rotate(start_angle, about_point=pointer.get_center()) + + + flow = StreamLines( + curl, + virtual_time=2, + min_magnitude=0, + max_magnitude=1, + dt = 0.1, + x_min = -0.5, x_max = 0.5, y_min = -0.5, y_max = 0.5, + ).scale(0.05).move_to(dot.get_center()) + flow_1 = AnimatedStreamLines( + flow, + line_anim_class=ShowPassingFlashWithThinningStrokeWidth + ) + + + # all the text + text_zoomed = TexMobject(r"\oint_{C_{i}} \vec F \cdot \vec dr = (\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}).", r" \mid D_{i} \mid").add_background_rectangle() + text_gen_1 = TexMobject(r"\sum_{i = 1}^{n}\oint_{C_{i}} \vec F \cdot \vec dr = \sum_{i = 1}^{n} (\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}). \mid D_{i} \mid").add_background_rectangle() + text_gen_2 = TexMobject(r"\oint_{C} \vec F \cdot \vec dr = \sum_{i = 1}^{n} (\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}. \mid D_{i} \mid") + text_conclusion = TexMobject(r"\oint \vec F \cdot \vec dr = \int \int_D (\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}) dA").add_background_rectangle() + text_intuition = TexMobject(r"\oint_{C} \textit{Macroscopic curl } = \int \int_{D} \textit{Sum of microscopic curls }").add_background_rectangle() + + texts = VGroup(text_zoomed, text_gen_1, text_gen_2, text_conclusion, text_intuition).shift(2.8*DOWN).scale(0.8) + + self.add(vector_field, surface_a, dot_show, label) + self.wait() + self.activate_zooming(animate=True) + self.wait(2) + self.add(pointer) + def update_rotate_move(mob,alpha): + pointer.restore() + + angle = self.get_pending(box,alpha) + + pointer.move_to(box.point_from_proportion(alpha)) + pointer.rotate(angle, about_point=pointer.get_center()) + self.add(flow_1) + self.play(ShowCreation(text_zoomed)) + #self.play(ReplacementTransform(box, text_zoomed[1])) + #self.wait(2) + self.play( + UpdateFromAlphaFunc(pointer,update_rotate_move), + run_time=3, + ) + self.wait(3) + #self.play(ReplacementTransform(text_zoomed, text_gen_1)) + #self.wait(2) + #self.play(ReplacementTransform(text_gen_1, text_gen_2)) + + self.play( + self.get_zoomed_display_pop_out_animation(), + # -------> Inverse + rate_func=lambda t: smooth(1-t), + ) + self.play( + Uncreate(zoomed_display_frame), + FadeOut(frame), + ) + self.wait() + self.remove(pointer, flow_1, label, dot_show, label_box) + self.play(ReplacementTransform(text_zoomed, text_gen_1)) + self.wait(2) + self.play(FadeIn(text_conclusion), FadeOut(text_gen_1)) + self.wait(2) + self.play(FadeOut(text_conclusion), FadeIn(text_intuition)) + self.wait(2) + + + + + + + + + @staticmethod + def surface(t, v): + return np.array([ + v*np.sin(t), + np.cos(t), + 0 + ])
\ No newline at end of file |