summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/div-curl-grad-and-all-that/Curl and conservative fields/CurlTheorem_file3_measure-curl.py
blob: e7a324dee666a93b9a27c03fb0efe55f1d5fbaac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from manimlib.imports import *

def field_func(coordinate):
	x,y = coordinate[:2]
	return np.array([
					-y, 
					x,
					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):

		vector_field = VectorField(field_func)
		vec_field_for_flow = VectorField(field_func, x_min = -1.5, x_max = 1.5, y_min = -1.5, y_max = 1.5)
		flow_rep = StreamLines(
        	field_func,
			virtual_time=4,
			min_magnitude=0,
			max_magnitude=2,
			dt = 0.1,
			x_min = -1, x_max = 1, y_min = -1, y_max = 1,
			).set_color_by_gradient([BLUE_E, TEAL, WHITE])
		flow = AnimatedStreamLines(
			flow_rep,
			line_anim_class=ShowPassingFlashWithThinningStrokeWidth
			)
		boundary = Circle(radius = 2).set_color("#7FFF00")
		
		start_angle = self.get_pending(boundary, 0)

		pointer = Triangle(fill_opacity = 1).set_height(0.25).set_color("#ffff00")
		pointer.set_fill("#ffff00")
		pointer.move_to(boundary.get_start())
		pointer.rotate(- PI / 2)
		pointer.save_state()
		pointer.rotate(start_angle, about_point=pointer.get_center())
		sym_1 = TexMobject(r"\oint \vec F \cdot \vec dr").next_to(pointer, RIGHT, buff = SMALL_BUFF).scale(0.7).set_color("#ffff00").add_background_rectangle()
		sym_2 = TexMobject(r"\nabla \times \vec F").scale(0.7).set_color(TEAL).add_background_rectangle()

		self.play(ShowCreation(vector_field))
		self.wait()
		self.add(flow)
		self.play(Write(boundary), Write(sym_2))
		self.wait(2)
		self.play(Write(pointer))
		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(sym_1))
		self.wait()