summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file4_diracBasic.py
blob: 0c7f8e470c92125c37d8ea0560646bc6e920e972 (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
from manimlib.imports import *
import math
import pylatex

class intro(GraphScene,Scene):
    CONFIG = {
        "x_min": -9,
        "x_max": 9,
        "y_min": -5,
        "y_max": 5,
        "graph_origin": ORIGIN+DOWN,
        "function_color": RED,
        "axes_color": GREEN,
        "x_axis_label": "$x$",
        "y_axis_label": "$\delta (x)$",
        "y_axis_height":4,
        "x_axis_width":7
    }
    def setup(self):
        GraphScene.setup(self)
        Scene.setup(self)
    def construct(self):
        introText=TextMobject("Dirac","Delta","Function")
        introText.set_color_by_tex_to_color_map({"Dirac":BLUE,"Delta":YELLOW})
        introText.scale(0.8)
        self.play(Write(introText))
        self.wait(0.5)
        self.play(ApplyMethod(introText.shift,3*UP))
        formulaa=TextMobject("$\delta (x)=\infty$","$x=0$")
        formulab=TextMobject("$\delta (x)=0$","$x\\neq 0$")
        formulaa.set_color_by_tex_to_color_map({"$x=0$":RED})
        formulab.set_color_by_tex_to_color_map({"$x\\neq 0$":RED})
        formulaa.scale(0.8)
        formulab.scale(0.8)
        formulab.shift(0.5*DOWN)
        self.play(FadeIn(formulaa),FadeIn(formulab))
        self.wait(1)

        self.play(FadeOut(formulaa),FadeOut(formulab))

        x_each_unit = self.x_axis_width / (self.x_max - self.x_min)
        y_each_unit = self.y_axis_height / (self.y_max - self.y_min)

        self.setup_axes(animate=True)
        self.wait(0.8)

        functionUpLine=Line(start=self.graph_origin,end=self.graph_origin+UP*y_each_unit*5,color=RED)
        functionDownLine=Line(start=self.graph_origin+UP*y_each_unit*5,end=self.graph_origin,color=RED)
        functinLeftLine=Line(start=self.graph_origin+LEFT*x_each_unit*9,end=self.graph_origin,color=RED)
        functionRightLine=Line(start=self.graph_origin,end=self.graph_origin+RIGHT*x_each_unit*9,color=RED)
        functionUpLine.shift(0.02*LEFT)
        functionRightLine.shift(0.02*RIGHT)

        self.play(ShowCreation(functinLeftLine))
        self.play(ShowCreation(functionUpLine))
        self.play(ShowCreation(functionDownLine))
        self.play(ShowCreation(functionRightLine))
        self.wait(1.5)

        self.play(FadeOut(self.axes),FadeOut(introText),FadeOut(functinLeftLine),FadeOut(functionRightLine),FadeOut(functionUpLine),FadeOut(functionDownLine))
        self.wait(0.5)