diff options
author | Somnath Pandit | 2020-06-30 01:43:11 +0530 |
---|---|---|
committer | Somnath Pandit | 2020-06-30 01:43:11 +0530 |
commit | c5c9807d2b6262a2805054c036a7486f57e766df (patch) | |
tree | 56af31a1059295ab4a8d791ea1be5db6501146fb /FSF-2020 | |
parent | 58b9da3540c18794cd10562971c4841df3e98527 (diff) | |
download | FSF-mathematics-python-code-archive-c5c9807d2b6262a2805054c036a7486f57e766df.tar.gz FSF-mathematics-python-code-archive-c5c9807d2b6262a2805054c036a7486f57e766df.tar.bz2 FSF-mathematics-python-code-archive-c5c9807d2b6262a2805054c036a7486f57e766df.zip |
extended animation
Diffstat (limited to 'FSF-2020')
2 files changed, 60 insertions, 21 deletions
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.gif Binary files differindex e165a15..6a57cab 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.py index 13211e9..fc56306 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.py @@ -3,10 +3,10 @@ from manimlib.imports import * class VectorFields(GraphScene): CONFIG = { - "x_min" : -2, - "x_max" : 2, - "y_min" : -2, - "y_max" : 2, + "x_min" : -4, + "x_max" : 4, + "y_min" : -4, + "y_max" : 4, "graph_origin": ORIGIN+2.5*LEFT, "x_axis_width": 7, "y_axis_height": 7, @@ -18,15 +18,15 @@ class VectorFields(GraphScene): "min_magnitude": 0, "max_magnitude": 4, "colors": [GREEN,GREEN,YELLOW,RED], - "length_func": lambda norm : .6*sigmoid(norm), + "length_func": lambda n: n/2.5, "opacity": .75, "vector_config": { "stroke_width":6, - "max_stroke_width_to_length_ratio":6 + "max_stroke_width_to_length_ratio":4 }, }, - "a":-1.5 ,"b": 2, "c": -1.5 ,"d": 2, + "a":-3.5 ,"b": 4, "c": -3.5 ,"d": 4, } def construct(self): @@ -35,27 +35,30 @@ class VectorFields(GraphScene): self.X=X ;self.Y=Y self.setup_axes(animate=False) - - vector_field=self.get_vector_field( - lambda v: np.array([ + vector_function = lambda v: np.array([ (v[0]-self.graph_origin[0])*(v[1]-self.graph_origin[1]), -(v[0]-self.graph_origin[0]), 0, ]) - ) + + vector_field=self.get_vector_field( + vector_function, + colors= [GREEN] + ) self.show_points() self.wait(.5) self.show_func_machine() self.wait(1) self.produce_vectors(vector_field) + self.wait(.5) + self.scale_down_vectors(vector_function) self.wait(2) - def show_points(self): - dn=.5 + dn=1 x_vals=np.arange(self.a,self.b,dn) y_vals=np.arange(self.c,self.d,dn) dots=VGroup() @@ -84,7 +87,9 @@ class VectorFields(GraphScene): ).set_color_by_gradient( *self.default_vector_field_config["colors"] ).next_to(machine,IN) - self.add(machine,machine_label) + + machine=VGroup(machine,machine_label) + self.add(machine) self.func_machine=machine @@ -92,6 +97,7 @@ class VectorFields(GraphScene): def produce_vectors(self,vector_field): count,i=3,0 self.run_time=1 + non_scaled_vectors=VGroup() for dot in self.dots: if i==count: self.run_time=.05 @@ -99,8 +105,11 @@ class VectorFields(GraphScene): vect= vector_field.get_vector(position) self.go_to_machine(dot) self.take_vec_from_machine(vect,position) + non_scaled_vectors.add(vect) i+=1 + self.non_scaled_vectors=non_scaled_vectors + def go_to_machine(self,dot): if self.run_time>.5: self.play(ApplyMethod( @@ -113,14 +122,19 @@ class VectorFields(GraphScene): def take_vec_from_machine(self,vect,position): vect.next_to(self.func_machine,DOWN,buff=.1) + if self.run_time>.5: + point_coord=TexMobject( + "(x_i,y_i)" + ).next_to(self.dot,RIGHT,buff= .01).scale(.75) + input_point=VGroup(point_coord, self.dot) self.play( ApplyMethod( - self.dot.shift,DOWN, + input_point.shift,DOWN, run_time=self.run_time )), self.play( - FadeOut(self.dot), + FadeOut(input_point), run_time=.2 ) self.play( @@ -130,15 +144,40 @@ class VectorFields(GraphScene): else: self.remove(self.dot) self.add(vect) - self.wait(.1) + self.wait(1.0/15) self.play( - ApplyMethod( - vect.move_to,position - ), + vect.move_to,position, run_time=self.run_time ) - + + def scale_down_vectors(self,vector_function): + scale_down_text=TextMobject( + r"Vectors are rescaled\\ for clarity\\ and \\", + r"colors are used to \\ indicate magnitudes", + stroke_width=1.2 + ) + scale_down_text[0][:7].set_color(BLUE) + scale_down_text[1].set_color_by_gradient( + *self.default_vector_field_config["colors"] + ) + scale_down_text.to_corner(UR).shift(DOWN) + scaled_vector_field= self.get_vector_field( + vector_function, + length_func= lambda norm : .75*sigmoid(norm) + ) + for vector in self.non_scaled_vectors: + scaled_vect= scaled_vector_field.get_vector(vector.get_center()) + vector.target= scaled_vect + + self.play(FadeOut(self.func_machine)) + self.play(Write(scale_down_text)) + self.wait(1.2) + self.play(LaggedStartMap( + MoveToTarget, self.non_scaled_vectors, + run_time=3 + )) + def get_vector_field(self,func,**kwargs): config = dict() config.update(self.default_vector_field_config) |