summaryrefslogtreecommitdiff
path: root/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py
blob: 984db16814cdf4460f580295017ea5e16201b5a7 (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
from manimlib.imports import*

class TangenttoSurface(ThreeDScene):

    def construct(self):
        axes = ThreeDAxes() 
        
        #----f(x,y): x**2+y**2
        p = 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) 

        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) 

        r2 = Rectangle(height = 2, breadth = 1,color = GREEN, fill_opacity=0.3).scale(0.5)

        self.add(axes)
        self.play(Write(r))
        self.play(Write(p),Write(d))
        self.play(ShowCreation(line1),ShowCreation(line2))
        self.wait(2)
        
        self.play(FadeOut(line1),FadeOut(line2),ReplacementTransform(p,r2))
        self.add_fixed_in_frame_mobjects(h_text)
        self.wait(1)