from manim import *
class CircleFromThreePoints(Scene):
    """3.2 Circle.from_three_points(p1, p2, p3) 过任意三个不共线的点画圆。
    下面先把三点画出来，再生成圆，可以直观看到圆同时经过这三点。
    """
    def construct(self):
        title = Text("三点画圆 from_three_points", font="STLiti", font_size=32).to_edge(UP)
        d1 = Dot(RIGHT, color=RED)
        d2 = Dot(UL, color=BLUE)
        d3 = Dot(DR, color=GREEN)
        dots = VGroup(d1, d2, d3)
        circle = Circle.from_three_points(
            d1.get_center(), d2.get_center(), d3.get_center(), color=YELLOW)
        caps = VGroup(
            Text("P1", font="STLiti", font_size=24).next_to(d1, UR, buff=0.1),
            Text("P2", font="STLiti", font_size=24).next_to(d2, UL, buff=0.1),
            Text("P3", font="STLiti", font_size=24).next_to(d3, DR, buff=0.1),
        )
        VGroup(circle, dots, caps).scale(1.2)
        note = Text("圆同时经过 P1 / P2 / P3", font="STLiti", font_size=26).to_edge(DOWN)
        self.play(Write(title), run_time=0.8)
        self.play(FadeIn(dots), FadeIn(caps), run_time=1.0)
        self.play(Create(circle), run_time=1.4)
        self.play(FadeIn(note), run_time=0.6)
        self.wait(2.4)
