diff options
author | Padmapriya Mohan | 2020-07-20 14:33:10 +0530 |
---|---|---|
committer | Padmapriya Mohan | 2020-07-20 14:33:10 +0530 |
commit | bcd70e78f623191176ece96184ec1fa39c6f30b1 (patch) | |
tree | af86d500ce2438c971fd45a61c3bc7be11a4a1da /FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file9_formal-def.py | |
parent | d72ba1b05700096a2c42e9616e30a939e9b921a6 (diff) | |
download | FSF-mathematics-python-code-archive-bcd70e78f623191176ece96184ec1fa39c6f30b1.tar.gz FSF-mathematics-python-code-archive-bcd70e78f623191176ece96184ec1fa39c6f30b1.tar.bz2 FSF-mathematics-python-code-archive-bcd70e78f623191176ece96184ec1fa39c6f30b1.zip |
files with gifs
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file9_formal-def.py')
-rw-r--r-- | FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file9_formal-def.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file9_formal-def.py b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file9_formal-def.py new file mode 100644 index 0000000..ecafca4 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and Div/DivCurl_file9_formal-def.py @@ -0,0 +1,82 @@ +from manimlib.imports import * +import numpy as np + + + +def func(coordinate): + x,y = coordinate[:2] + return np.array([ + 1.9*np.cos(x+2*y), + 1.5*np.sin(x-2*y), + 0 + ]) + +def coord(x,y,z=0): + return np.array([x,y,z]) + +class Instrument(Scene): + CONFIG = { + "x_coords": ([1, 2.2, 3.9, 3, -0, -0.2, 1]), + "y_coords": ([1.5, 1, -0.5, -2.0, -1.4, 0.5, 1.5]), + } + + def setup(self): + self.tuples = list(zip(self.x_coords,self.y_coords)) + dots = self.get_all_mobs() + + def get_dots(self, coords): + dots = VGroup(*[Dot(coord(x,y)) for x,y in coords]) + return dots + + def get_all_mobs(self): + dots = self.get_dots(self.tuples) + return dots + + +class Curl_one(MovingCameraScene, Instrument): + def setup(self): + MovingCameraScene.setup(self) + Instrument.setup(self) + + + def construct(self): + vec = VectorField(func) + + + frame_one = Circle(radius = 0.5).move_to(np.array([4, 2, 0])) + dot = Dot(frame_one.get_center()).scale(0.5) + surface = VMobject() + surface.set_points_smoothly([*[coord(x,y) for x,y in self.tuples]]) + surface.move_to(dot.get_center()).set_stroke(width = 0.5) + + label = TexMobject(r"A").scale(0.5).next_to(dot, LEFT+UP, buff = SMALL_BUFF) + #self.add(frame_one) + self.camera_frame.save_state() + self.play( + self.camera_frame.set_width,frame_one.get_width()*7.0, + self.camera_frame.move_to,frame_one) + + + + + self.add(vec, dot, label) + lines = StreamLines( + func, + virtual_time=7, + min_magnitude=0, + max_magnitude=8, + ) + lines1 = AnimatedStreamLines( + lines, + line_anim_class=ShowPassingFlashWithThinningStrokeWidth + ) + + self.add(lines1) + self.wait(3) + self.play(Restore(self.camera_frame)) + self.wait(2) + self.add(surface) + self.wait(3) + self.play(ApplyMethod(surface.scale, 0.01), run_time = 2) + self.remove(surface) + self.wait(2) |