Repository: ManimCommunity/manim
File: tests/test_graphical_units/test_geometry.py (Python)

Code before:
    circle = Circle().set_fill(RED, opacity=1)
    square = Square(side_length=1.7).set_fill(BLUE, opacity=1)
    triangle = Triangle().set_fill(GREEN, opacity=1)
    square.z_index = 0
    triangle.z_index = 1
    circle.z_index = 2

    scene.play(FadeIn(VGroup(circle, square, triangle)))
    scene.play(ApplyMethod(circle.shift, UP))
    scene.play(ApplyMethod(triangle.shift, 2 * UP))


@frames_comparison
def test_Angle(scene):
    l1 = Line(ORIGIN, RIGHT)
    l2 = Line(ORIGIN, UP)
    a = Angle(l1, l2)
    scene.add(a)


@frames_comparison
def test_three_points_Angle(scene):
    A = np.array([3, 5, 0])
    B = np.array([0, 0, 0])
    C = np.array([8, 0, 0])
    a = Angle.from_three_points(A, B, C)
    scene.add(a)


@frames_comparison
def test_RightAngle(scene):
    l1 = Line(ORIGIN, RIGHT)
    l2 = Line(ORIGIN, UP)
    a = RightAngle(l1, l2)
    scene.add(a)


@frames_comparison
def test_Polygram(scene):
    hexagram = Polygram(
        [[0, 2, 0], [-np.sqrt(3), -1, 0], [np.sqrt(3), -1, 0]],
        [[-np.sqrt(3), 1, 0], [0, -2, 0], [np.sqrt(3), 1, 0]],
    )
    scene.add(hexagram)


@frames_comparison
def test_RegularPolygram(scene):
    pentagram = RegularPolygram(5, radius=2)
    octagram = RegularPolygram(8, radius=2)
    scene.add(VGroup(pentagram, octagram).arrange(RIGHT))

Review comment (suggestion):
It would be good to have a test where multiple cases for positions of the points A, B, C are constructed (what happens if A and C are close? Is the correct angle constructed when A and C swap?). It is not necessary to assign A B C to variables, the method can simply be called via `Angle.from_three_points([...], [...], [...])`.

Code after:
    circle = Circle().set_fill(RED, opacity=1)
    square = Square(side_length=1.7).set_fill(BLUE, opacity=1)
    triangle = Triangle().set_fill(GREEN, opacity=1)
    square.z_index = 0
    triangle.z_index = 1
    circle.z_index = 2

    scene.play(FadeIn(VGroup(circle, square, triangle)))
    scene.play(ApplyMethod(circle.shift, UP))
    scene.play(ApplyMethod(triangle.shift, 2 * UP))


@frames_comparison
def test_Angle(scene):
    l1 = Line(ORIGIN, RIGHT)
    l2 = Line(ORIGIN, UP)
    a = Angle(l1, l2)
    scene.add(a)


@frames_comparison
def test_three_points_Angle(scene):
    # acute angle
    acute = Angle.from_three_points(
        np.array([10, 0, 0]), np.array([0, 0, 0]), np.array([10, 10, 0])
    )
    # obtuse angle
    obtuse = Angle.from_three_points(
        np.array([-10, 1, 0]), np.array([0, 0, 0]), np.array([10, 1, 0])
    )
    # quadrant 1 angle
    q1 = Angle.from_three_points(
        np.array([10, 10, 0]), np.array([0, 0, 0]), np.array([10, 1, 0])
    )
    # quadrant 2 angle
    q2 = Angle.from_three_points(
        np.array([-10, 1, 0]), np.array([0, 0, 0]), np.array([-1, 10, 0])
    )
    # quadrant 3 angle
    q3 = Angle.from_three_points(
        np.array([-10, -1, 0]), np.array([0, 0, 0]), np.array([-1, -10, 0])
    )
    # quadrant 4 angle
    q4 = Angle.from_three_points(
        np.array([10, -1, 0]), np.array([0, 0, 0]), np.array([1, -10, 0])
    )
    scene.add(VGroup(acute, obtuse, q1, q2, q3, q4).arrange(RIGHT))


@frames_comparison
def test_RightAngle(scene):