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

class TangenttoSurface(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes() 
        
        #parabola: -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=[BLUE_C,TEAL_D],
            resolution=(20, 20)).scale(1).shift(1*RIGHT+2*UP)
        self.set_camera_orientation(phi = 35 * DEGREES,theta = -40 * DEGREES )            

        r = Rectangle(side_length=2,side_breadth= 1, fill_color=PURPLE, fill_opacity=0.2).shift(ORIGIN-1+3*UP+2*RIGHT).scale(0.7) #---tangent plane along x axis
        
        r_text = TextMobject("Tangent Plane along $x$ axis",color = '#FFE4E1').scale(0.6).to_corner(UL)
        r2_text = TextMobject("Tangent Plane along $y$ axis",color = '#FFE4E1').scale(0.6).to_corner(UL)  

        a = Arrow(color = '#FFFFF0').shift(ORIGIN-1+3*UP+4*RIGHT).scale(0.5) 
        a2 = Arrow(color = '#FFFFF0').shift(ORIGIN+0.5+3*UP+RIGHT).scale(0.5)
        a2.rotate(1.571) #----1.571 radian = 90 degrees
        
        self.add(axes)
        self.play(Write(p))
        self.begin_ambient_camera_rotation(rate = 0.1)
        self.add_fixed_in_frame_mobjects(r_text)
        self.play(ShowCreation(r))
        self.play(ShowCreation(a))
        self.wait(1)        
        self.play(FadeOut(r),FadeOut(a),FadeOut(r_text))

        r.rotate(1.571) #---tangent plane along y axis
        self.play(ShowCreation(r))
        self.play(ShowCreation(a2))
        self.add_fixed_in_frame_mobjects(r2_text)
        self.wait(2)