summaryrefslogtreecommitdiff
path: root/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations
diff options
context:
space:
mode:
Diffstat (limited to 'FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations')
-rw-r--r--FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py90
1 files changed, 65 insertions, 25 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py
index 984db16..d1ecf8c 100644
--- a/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py
+++ b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py
@@ -1,34 +1,74 @@
from manimlib.imports import*
-class TangenttoSurface(ThreeDScene):
-
+#---- tangent plane is parallel to the x-y plane
+class MaximaScene(ThreeDScene):
def construct(self):
- axes = ThreeDAxes()
-
- #----f(x,y): x**2+y**2
- p = ParametricSurface(
+
+ axes = ThreeDAxes().scale(1.2)
+ label_x= TextMobject("$x$").shift([5.4,-0.5,0]) #---- x axis
+ label_y= TextMobject("$y$").shift([-0.5,5.2,0]).rotate(-4.5) #---- y axis
+
+ #---- graph of the function
+ s = 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 = [GREEN_C,GREEN_D],
- resolution = (20, 20)).scale(1)
- self.set_camera_orientation(phi = 75*DEGREES)
+ 1.5*np.cos(u)*np.cos(v),
+ 1.5*np.cos(u)*np.sin(v),
+ 1.5*np.sin(u)
+ ]),u_min=0,u_max=PI,v_min=PI,v_max=2*PI,checkerboard_colors=[BLUE_B,BLUE_C,BLUE_D,BLUE_E]).scale(1.5).shift([-0.8,0.5,1.5])
- h_text = TextMobject("The graph tends to coincide with its tangent plane").scale(0.5).to_corner(UL)
- d = Dot([0,0,0],color ='#800000') #----critical point
- r = Rectangle(height = 2,breadth = 1,color = YELLOW).scale(0.5) #----tangent plane to critical point
- line1 = DashedLine(color=RED).shift(4*UP+1.3*RIGHT).rotate(1.571,UP).scale(1.2)
- line2 = DashedLine(color=RED).shift(4*UP-1.3*RIGHT).rotate(1.571,UP).scale(1.2)
+ d1 = Dot([0.2,2.01,2.24],color = '#800000').rotate(1.1,LEFT) #---- point(x_0,y_0)
+ d1_copy = Dot([1.1,2.2,-0.45],color = '#800000') #---- projection of point(x_0,y_0) on x-y plane
+ d1_text = TextMobject("$(x_0,y_0)$",color = "#8B0000").scale(0.4).shift(1.3*RIGHT+1.1*UP)
- r2 = Rectangle(height = 2, breadth = 1,color = GREEN, fill_opacity=0.3).scale(0.5)
+ d2 = Dot([1.1,2.2,2.7],color = '#800000').rotate(1,LEFT) #---- point(x,y)
+ d2_copy = Dot([0.1,1.95,0.4],color = '#800000') #---- projection of point(x,y) on x-y plane
+ d2_text = TextMobject("$(x,y)$",color = "#8B0000").scale(0.4).shift(0.6*RIGHT+0.8*UP)
- self.add(axes)
- self.play(Write(r))
- self.play(Write(p),Write(d))
- self.play(ShowCreation(line1),ShowCreation(line2))
- self.wait(2)
+ t_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(1,LEFT).shift([1.1,2.5,2.9]) #---- tangent plane
+
+ t_text= TextMobject("Tangent Plane",color = RED).scale(0.5).shift(0.3*RIGHT+1.3*UP).rotate(math.radians(5),LEFT)
+
+ l1 = Line([1.1,2.2,2.6],[1.1,2.2,-0.45]).fade(0.2)
+ l2 = Line([0.1,1.95,2.05],[0.1,1.95,0.4]).fade(0.2)
+
+ a1 = Line([0.1,1.95,0.4],[1.1,2.2,-0.45],color ="#00FF7F")
+ a_x = Line([0.1,1.95,0.4],[1.7,1.95,0.4],color ="#9400D3")
+ a_y = Line([0.1,1.95,0.4],[0.1,2.75,0.4],color ="#8B4513")
+ a2 = Line([1.7,1.95,0.4],[1.7,2.75,0.4])
+ a3 = Line([0.1,2.75,0.4],[1.7,2.75,0.4])
- self.play(FadeOut(line1),FadeOut(line2),ReplacementTransform(p,r2))
- self.add_fixed_in_frame_mobjects(h_text)
+ #---- transition of tangent plane
+
+ t2_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(1,LEFT).shift([1.1,2.5,2])
+ t3_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(math.radians(180),LEFT).shift([1.1,2.5,2])
+ t4_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(math.radians(180),LEFT).shift([0.9,2.35,0.4])
+
+ #-------------------------------------------
+ self.set_camera_orientation(phi = 50 * DEGREES, theta = 45 * DEGREES)
+ self.wait(1)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.play(Write(s))
+ self.wait(1)
+ self.play(Write(d1))
+ self.add_fixed_in_frame_mobjects(d1_text)
+ self.play(ShowCreation(t_plane))
+ self.add_fixed_in_frame_mobjects(t_text)
+ self.wait(1)
+ self.play(FadeOut(t_text),Write(d2))
+ self.add_fixed_in_frame_mobjects(d2_text)
+ self.wait(1)
+ self.play(Write(l1),Write(l2))
+ self.play(Write(d2_copy),Write(d1_copy))
+ self.wait(1)
+ self.play(Write(a1),Write(a_x),Write(a_y))
+ self.wait(1)
+ self.play(Write(a2),Write(a3))
+ self.wait(1)
+ self.play(ReplacementTransform(t_plane,t2_plane))
+ self.wait(1)
+ self.play(ReplacementTransform(t2_plane,t3_plane))
self.wait(1)
+ self.play(ReplacementTransform(t3_plane,t4_plane))
+ self.wait(1)