diff options
2 files changed, 93 insertions, 55 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Tangent_plane_at_extrema.py b/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Tangent_plane_at_extrema.py deleted file mode 100644 index 6889a52..0000000 --- a/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Tangent_plane_at_extrema.py +++ /dev/null @@ -1,55 +0,0 @@ -from manimlib.imports import* - -class TheoremAnimation(ThreeDScene): - def construct(self): - - axes = ThreeDAxes() - - #----parabola: x**2+y**2 - parabola1 = ParametricSurface( - lambda u, v: np.array([ - u, - v, - u**2+v**2 - ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[TEAL_E], - resolution=(20, 20)).scale(1) - - #----parabola: -x**2-y**2 - parabola2 = ParametricSurface( - lambda u, v: np.array([ - u, - v, - -u**2-v**2 - ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[PURPLE_E,PURPLE_E], - resolution=(20, 20)).scale(1) - - self.set_camera_orientation(phi=75 * DEGREES) - self.begin_ambient_camera_rotation(rate=0.4) - - d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point - r = Rectangle(fill_color= '#C0C0C0',fill_opacity =0.3).move_to(ORIGIN) #----tangent plane - - parabola1_text = TextMobject("Maximum with horizontal tangent plane").scale(0.7).to_corner(UL) - - parabola2_text = TextMobject("Minimum with horizontal tangent plane").scale(0.7).to_corner(UL) - - self.add(axes) - self.add_fixed_in_frame_mobjects(parabola2_text) - self.wait(1) - self.play(Write(parabola1)) - self.wait(1) - self.play(ShowCreation(d)) - self.wait(1) - self.play(ShowCreation(r)) - self.wait(2) - self.play(FadeOut(parabola2_text),FadeOut(parabola1),FadeOut(r),FadeOut(d)) - - self.wait(1) - self.add_fixed_in_frame_mobjects(parabola1_text) - self.wait(1) - self.play(Write(parabola2)) - self.wait(1) - self.play(ShowCreation(d)) - self.wait(1) - self.play(ShowCreation(r)) - self.wait(2) diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py b/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py new file mode 100644 index 0000000..65b4414 --- /dev/null +++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py @@ -0,0 +1,93 @@ +from manimlib.imports import* +import math as m + + +class firstScene(ThreeDScene): + def construct(self): + + axes = ThreeDAxes().scale(1.15) + surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + m.exp(-10*u**2-10*v**2) #---- f(x,y) + ]),u_min=-2,u_max=1, v_min=-1,v_max=1,checkerboard_colors=[PURPLE_C,PURPLE_D,PURPLE_E,PURPLE_B]).scale(3).shift([1.1,0.48,1.731]) + + trace = ParametricSurface( + lambda u, v: np.array([ + m.exp(np.cos(v)+np.sin(v)), + v, + u/4 + ]), v_min = -1, v_max= 2).rotate(1.571,DOWN).shift(2.15*LEFT+[0.6,-0.4,1.54]).scale(1).set_color('#800000') + + + + d = Dot(color =YELLOW).shift([1.9,0.7,4.1]) #---- critical point + tangent_line = Line(color = '#228B22').scale(1).shift([1.9,0.7,4.1]).rotate(4.5) #---- tangent along y axis + + label_x = TextMobject("$x$").shift([5.8,-0.5,0]) + label_y = TextMobject("$y$").shift([-0.5,5.6,0]).rotate(-4.5) + + + f_text = TextMobject("Tangent to the trace with $y$ constant at critical point").shift(3*RIGHT+2*UP).scale(0.5).to_corner(UL) + + self.add(axes) + self.set_camera_orientation(phi=60*DEGREES,theta=15*DEGREES) + self.add(label_x) + self.add(label_y) + self.play(Write(surface)) + self.wait(1) + self.add_fixed_in_frame_mobjects(s_text) + self.add(trace) + self.wait(1) + self.play(Write(tangent_line),Write(d)) + self.wait(2) + + +class secondScene(ThreeDScene): + def construct(self): + + axes = ThreeDAxes().scale(1.15) + surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + m.exp(-10*u**2-10*v**2) #---- f(x,y) + ]),u_min=-2,u_max=1, v_min=-1,v_max=1,checkerboard_colors=[PURPLE_C,PURPLE_D,PURPLE_E,PURPLE_B]).scale(3).shift([1.1,0.48,1.731]) + + trace = ParametricSurface( + lambda u, v: np.array([ + m.exp(np.cos(v)+np.sin(v)), + v, + u/4 + ]), v_min = -1, v_max= 2).rotate(1.571,DOWN).shift(2.15*LEFT+[0.6,-0.4,1.54]).scale(1).set_color('#800000') + + + + d = Dot(color =YELLOW).shift([1.9,0.7,4.1]) #---- critical point + + label_x = TextMobject("$x$").shift([5.8,-0.5,0]) + label_y = TextMobject("$y$").shift([-0.5,5.6,0]).rotate(-4.5) + + f_text = TextMobject("Tangent to the trace with $y$ constant at critical point").shift(3*RIGHT+2*UP).scale(0.5).to_corner(UL) + + tangent_line = Line(color = '#228B22').scale(1).shift([1.9,0.7,4.1]) #---- tangent along x axis + + + self.add(axes) + self.set_camera_orientation(phi=60*DEGREES,theta=15*DEGREES) + self.add(label_x) + self.add(label_y) + self.play(Write(surface)) + self.wait(1) + self.add_fixed_in_frame_mobjects(f_text) + trace.rotate(-5).shift(0.2*RIGHT+0.8*UP+[0.6,-0.4,0.6]) + self.add(trace) + self.play(Write(tangent_line),Write(d)) + self.wait(1) + + + + + + |