summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_tnb_creation.py
blob: 80372ee1a3f63debff65c1bf32aa43192d5f3e90 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from manimlib.imports import *

class tnb(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES)

        helix1 = ParametricFunction(
                lambda t: np.array([
                np.cos(TAU*t),
                np.sin(TAU*t),
                0.4*t
                ]), t_min = -2*np.pi/3, t_max = -1.638*np.pi/3, color = WHITE
                )

        helix2 = ParametricFunction(
                lambda t: np.array([
                np.cos(TAU*t),
                np.sin(TAU*t),
                0.4*t
                ]), t_min = -1.638*np.pi/3, t_max = -1.33*np.pi/3, color = WHITE
                )

        pointText = TextMobject(r'Consider an arbitrary point \\ on the given curve.').scale(0.8).shift(1.5*UP)
        tgtText = TextMobject(r'Unit', ' tangent ', r'vector at \\ this point is given as:').scale(0.8).shift(1.5*UP)
        tgtText.set_color_by_tex_to_color_map({
            "tangent": YELLOW
        })
        normalText = TextMobject(r'Unit', ' normal ', r'vector at \\ this point is given as:').scale(0.8).shift(1.5*UP)
        normalText.set_color_by_tex_to_color_map({
            "normal": BLUE
        })
        planeText = TextMobject(r'$\overrightarrow{T}$ and $\overrightarrow{N}$ \\ prescribe a plane.').scale(0.8).shift(1.5*UP)
        bnmText = TextMobject(r'The vector normal to this plane \\ is called the', ' binormal ', 'vector.').scale(0.8).shift(1.5*UP)
        bnmText.set_color_by_tex_to_color_map({
            "binormal": GREEN_E
        })

        dot1 = Dot(np.array([np.cos(-np.pi/3), np.sin(-np.pi/3), -0.4*np.pi/3]) + np.array([0,0.2,0]), radius = 0.16, color=RED)
        tgt1 = Arrow((0,0,0), (-2,-0.55,0), color = YELLOW).shift(dot1.get_center() + np.array([0.18,0.04,0]))
        nm1 = Arrow((0,0,0), (0.4,-2,0), color = BLUE).shift(dot1.get_center() + np.array([0,0.26,0]))
        bnm1 = Arrow((0,0,0), (0,2,0), color=GREEN_E).shift(2.1*RIGHT+2*DOWN)
        plane1 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot1.get_center() + np.array([-0.4, -0.6, 0])).rotate(13*DEGREES).scale(1.2)
        point1 = VGroup(*[dot1, tgt1, nm1, plane1]).scale(0.8).shift(np.array([1,4.86,0])).rotate(-15*DEGREES)



        helix = VGroup(*[helix1, helix2])
        self.play(FadeIn(helix))
        self.play(ApplyMethod(helix.scale, 4))
        self.add_fixed_in_frame_mobjects(pointText)
        self.play(FadeIn(dot1), FadeIn(pointText))
        self.wait(2)
        self.add_fixed_in_frame_mobjects(tgtText)
        self.play(Write(tgt1), ReplacementTransform(pointText, tgtText))
        self.wait(2)
        self.add_fixed_in_frame_mobjects(normalText)
        self.play(Write(nm1), ReplacementTransform(tgtText, normalText))
        self.wait(2)
        self.add_fixed_in_frame_mobjects(planeText)
        self.play(FadeIn(plane1), ReplacementTransform(normalText, planeText))
        self.wait(2)
        self.add_fixed_in_frame_mobjects(bnmText)
        self.add_fixed_in_frame_mobjects(bnm1)
        self.play(ReplacementTransform(planeText, bnmText), Write(bnm1))
        self.wait(2)
        self.play(FadeOut(VGroup(*[helix, bnm1, bnmText, dot1, tgt1, nm1, plane1])))