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

Code before:


@frames_comparison(last_frame=False)
def test_ZIndex(scene):
    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])
    )
    scene.add(acute)
    # obtuse angle
    obtuse = Angle.from_three_points(
        np.array([-10, 1, 0]), np.array([0, 0, 0]), np.array([10, 1, 0])
    )
    scene.add(obtuse)
    # quadrant 1 angle
    q1 = Angle.from_three_points(
        np.array([10, 10, 0]), np.array([0, 0, 0]), np.array([10, 1, 0])
    )
    scene.add(q1)
    # quadrant 2 angle
    q2 = Angle.from_three_points(
        np.array([-10, 1, 0]), np.array([0, 0, 0]), np.array([-1, 10, 0])
    )
    scene.add(q2)
    # quadrant 3 angle
    q3 = Angle.from_three_points(
        np.array([-10, -1, 0]), np.array([0, 0, 0]), np.array([-1, -10, 0])
    )
    scene.add(q3)

Review comment (suggestion):
I think this test could be improved a bit: take a look at the rendered test output:

![image](https://user-images.githubusercontent.com/11851593/164542973-a66cec47-5a17-4574-bfde-cff133ec4fc6.png)

If there was a problem with any of the angles, it would be very hard to distinguish visually where the problem occurs. I suggest to `VGroup(acute, obtuse, q1, q2, q3, q4).arrange(RIGHT)` before adding all of the angles to the scene.

Code after:


@frames_comparison(last_frame=False)
def test_ZIndex(scene):
    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))