Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from manim import *
- import numpy as np
- def split_segment(A, B, k):
- N = np.array(
- [
- (A[0] + B[0] * k) / (1 + k),
- (A[1] + B[1] * k) / (1 + k),
- 0
- ]
- )
- return N
- class Mikel(Scene):
- def construct(self):
- A = np.array([-2, -2, 0])
- B = np.array([3, -2, 0])
- C = np.array([0, 3, 0])
- kwargs = {"radius": 0.05, "stroke_width": 0.75, "stroke_color": GREY_E, "z_index": 3, "stroke_opacity": 1}
- pA = always_redraw(lambda: Dot(A, **kwargs, fill_color=BLUE))
- pB = always_redraw(lambda: Dot(B, **kwargs, fill_color=BLUE))
- pC = always_redraw(lambda: Dot(C, **kwargs, fill_color=BLUE))
- ABC = always_redraw(lambda:
- Polygon(
- pA.get_center(), pB.get_center(), pC.get_center(), stroke_width = 2, stroke_color = BLUE_B, fill_opacity=0
- )
- )
- n = ValueTracker(4)
- m = ValueTracker(1.5)
- k = ValueTracker(0.3)
- pN = always_redraw(lambda:
- Dot(point = split_segment(pA.get_center(), pB.get_center(), n.get_value()), **kwargs, fill_color = GREEN_C)
- )
- pM = always_redraw(lambda:
- Dot(point = split_segment(pB.get_center(), pC.get_center(), m.get_value()), **kwargs, fill_color = GREEN_C)
- )
- pK = always_redraw(lambda:
- Dot(point = split_segment(pA.get_center(), pC.get_center(), k.get_value()), **kwargs, fill_color = GREEN_C)
- )
- circ1 = always_redraw(lambda:
- Circle.from_three_points(pA.get_center(), pN.get_center(), pK.get_center(), color = TEAL_C, stroke_width = 1.25)
- )
- circ2 = always_redraw(lambda:
- Circle.from_three_points(pB.get_center(), pN.get_center(), pM.get_center(), color = TEAL_C, stroke_width = 1.25)
- )
- circ3 = always_redraw(lambda:
- Circle.from_three_points(pC.get_center(), pM.get_center(), pK.get_center(), color = TEAL_C, stroke_width = 1.25)
- )
- self.play(GrowFromCenter(pA), GrowFromCenter(pB), GrowFromCenter(pC), Create(ABC), run_time=2, lag_ratio=0)
- self.wait(0.5)
- self.play(GrowFromCenter(pN), Flash(pN))
- self.play(GrowFromCenter(pM), Flash(pM))
- self.play(GrowFromCenter(pK), Flash(pK))
- self.wait(0.5)
- self.play(Create(circ1), run_time=1.5)
- self.wait(0.5)
- self.play(Create(circ2), run_time=1.5)
- self.wait(0.5)
- self.play(Create(circ3), run_time=1.5)
- self.wait()
- self.play(pC.animate.shift(3*LEFT), rate_func=there_and_back, run_time=4)
- self.wait(0.5)
- self.play(pC.animate.shift(3*RIGHT), rate_func=there_and_back, run_time=4)
- self.wait()
- self.play(
- AnimationGroup(
- n.animate.set_value(0.5),
- m.animate.set_value(0.7),
- k.animate.set_value(3),
- lag_ratio=0,
- run_time=4
- )
- )
- self.wait()
- inter = always_redraw(lambda:Intersection(circ2, circ3, stroke_opacity=0))
- Z = always_redraw(lambda: Dot(inter.get_corner(LEFT), **kwargs, fill_color = YELLOW))
- self.play(GrowFromCenter(Z), Flash(Z))
- self.wait(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement