Esempio n. 1
0
 def __init__(self, function, mobject = ComplexPlane, **kwargs):
     if "interpolation_function" not in kwargs:
         self.interpolation_function = path_along_arc(
             np.log(function(complex(1))).imag
         )
     ApplyPointwiseFunction.__init__(
         self,
         lambda (x, y, z) : complex_to_R3(function(complex(x, y))),
         instantiate(mobject),
         **kwargs
     )
Esempio n. 2
0
    def construct(self):
        mathy, bubble = get_mathy_and_bubble()
        squiggle_mouth = mathy.mouth.copy()
        squiggle_mouth.apply_function(
            lambda (x, y, z) : (x, y+0.02*np.sin(50*x), z)
        )
        bubble.ingest_submobjects()        
        bubble.write("Why not use a Hilbert curve \\textinterrobang ")
        words1 = bubble.content
        bubble.write("So, it's not one curve but an infinite family of curves \\dots")
        words2 = bubble.content
        bubble.write("Well, no, it \\emph{is} just one thing, but I need \\\\ \
                      to tell you about a certain infinite family first.")
        words3 =  bubble.content
        description = TextMobject("Mathematician friend", size = "\\small")
        description.next_to(mathy, buff = 2)
        arrow = Arrow(description, mathy)

        self.add(mathy)
        self.play(
            ShowCreation(arrow),
            ShimmerIn(description)
        )
        self.dither()
        point = Point(bubble.get_tip())
        self.play(
            Transform(point, bubble),
        )
        self.remove(point)
        self.add(bubble)
        self.play(ShimmerIn(words1))
        self.dither()
        self.remove(description, arrow)
        self.play(
            Transform(mathy.mouth, squiggle_mouth),
            ApplyMethod(mathy.arm.wag, 0.2*RIGHT, LEFT),
        )
        self.remove(words1)
        self.add(words2)
        self.dither(2)
        self.remove(words2)
        self.add(words3)
        self.dither(2)
        self.play(
            ApplyPointwiseFunction(
                lambda p : 15*p/np.linalg.norm(p),
                bubble
            ),
            ApplyMethod(mathy.shift, 5*(DOWN+LEFT)),
            FadeOut(words3),
            run_time = 3
        )
Esempio n. 3
0
 def apply_function(self, function, added_anims=[], **kwargs):
     if "run_time" not in kwargs:
         kwargs["run_time"] = 3
     anims = [
         ApplyPointwiseFunction(function, t_mob)
         for t_mob in self.transformable_mobjects
     ] + [
         self.get_vector_movement(function),
         self.get_transformable_label_movement(),
         self.get_moving_mobject_movement(function),
     ] + [Animation(f_mob)
          for f_mob in self.foreground_mobjects] + added_anims
     self.play(*anims, **kwargs)
Esempio n. 4
0
 def zoom_in_on_thought_bubble(self, bubble = None, radius = SPACE_HEIGHT+SPACE_WIDTH):
     if bubble is None:
         for pi in self.get_everyone():
             if hasattr(pi, "bubble") and isinstance(pi.bubble, ThoughtBubble):
                 bubble = pi.bubble
                 break
         if bubble is None:
             raise Exception("No pi creatures have a thought bubble")
     vect = -bubble.get_bubble_center()
     def func(point):
         centered = point+vect
         return radius*centered/np.linalg.norm(centered)
     self.play(*[
         ApplyPointwiseFunction(func, mob)
         for mob in self.get_mobjects()
     ])
Esempio n. 5
0
    def construct(self):
        mathy, bubble = get_mathy_and_bubble()
        bubble.sort_points(lambda p: np.dot(p, UP + RIGHT))

        self.add(mathy)
        self.dither()
        self.play(
            ApplyMethod(mathy.blink,
                        rate_func=squish_rate_func(there_and_back)))
        self.dither()
        self.play(ShowCreation(bubble))
        self.dither()
        self.play(ApplyMethod(mathy.shift, 3 * (DOWN + LEFT)),
                  ApplyPointwiseFunction(lambda p: 15 * p / np.linalg.norm(p),
                                         bubble),
                  run_time=3)
Esempio n. 6
0
 def __init__(self, function, mobject=ComplexPlane, **kwargs):
     if "path_func" not in kwargs:
         self.path_func = path_along_arc(np.log(function(complex(1))).imag)
     ApplyPointwiseFunction.__init__(
         self, lambda x, y, z: complex_to_R3(function(complex(x, y))),
         instantiate(mobject), **kwargs)