Repository: ManimCommunity/manim
File: manim/mobject/geometry.py (Python)

Code before:
            self,
            radius=radius,
            angle=angle_fin,
            start_angle=start_angle,
            arc_center=inter,
            **kwargs
        )
        if dot == True:
            if dot_radius == None:
                dot_radius = radius / 10
            else:
                self.dot_radius = dot_radius
            right_dot = Dot(ORIGIN, radius=dot_radius, color=dot_color)
            dot_anchor = (
                inter
                + (self.get_center() - inter)
                / np.linalg.norm(self.get_center() - inter)
                * radius
                * dot_distance
            )
            right_dot.move_to(dot_anchor)
            self.add(right_dot)


class RightAngle(VMobject):
    """An elbow-type mobject representing a right angle between two lines.

    Parameters
    ----------
    line1 : :class:`Line`
        The first line.
    line2 : :class:`Line`
        The second line.
    length : :class:`float`
        The length of the arms.
    quadrant : Sequence[:class:`int`]
        A sequence of two :class:`int` numbers determining which of the 4 quadrants should be used.
        The first value indicates whether to anchor the arc on the first line closer to the end point (1)
        or start point (-1), and the second value functions similarly for the end (1) or start (-1) of the second line.
        Possibilities: (1,1), (-1,1), (1,-1), (-1,-1).
    kwargs
        Further keyword arguments that are passed to the constructor of :class:`~.VMobject`.

    Examples
    --------

    ..manim:: RightAngleExample
        :save_last_frame:

        class RightAngleExample(Scene):
            def construct(self):

Review comment (refactor):
I agree with @WampyCakes that as this is *currently* written, it should inherit from Elbow, as the docstring clearly states it IS-A type of Elbow... but at the same time, I also think it would make more sense for RightAngle to inherit from Angle (currently ArcAngle) as it is a special type of Angle.

I think Angle should be the class to implement the core logic and `RightAngle` should act as a separate way to call Angle constructor with specific defaults that make this behave as expected (i.e. no dot, and no arc). Perhaps, Angle should inherit from both Arc and Elbow.

Either way, this should inherit from something which could make the code more DRY.

Code after:

        anchor_angle_1 = inter + quadrant[0] * radius * line1.get_unit_vector()
        anchor_angle_2 = inter + quadrant[1] * radius * line2.get_unit_vector()

        if elbow:
            anchor_middle = (
                inter
                + quadrant[0] * radius * line1.get_unit_vector()
                + quadrant[1] * radius * line2.get_unit_vector()
            )
            Elbow.__init__(self, **kwargs)
            self.set_points_as_corners([anchor_angle_1, anchor_middle, anchor_angle_2])
        else:
            angle_1 = angle_of_vector(anchor_angle_1 - inter)
            angle_2 = angle_of_vector(anchor_angle_2 - inter)

            if not other_angle:
                start_angle = angle_1
                if angle_2 > angle_1:
                    angle_fin = angle_2 - angle_1
                else:
                    angle_fin = 2 * np.pi - (angle_1 - angle_2)
            else:
                start_angle = angle_1
                if angle_2 < angle_1:
                    angle_fin = -angle_1 + angle_2
                else:
                    angle_fin = -2 * np.pi + (angle_2 - angle_1)

            Arc.__init__(
                self,
                radius=radius,
                angle=angle_fin,
                start_angle=start_angle,
                arc_center=inter,
                **kwargs
            )
            if dot:
                if dot_radius is None:
                    dot_radius = radius / 10
                else:
                    self.dot_radius = dot_radius
                right_dot = Dot(ORIGIN, radius=dot_radius, color=dot_color)
                dot_anchor = (
                    inter
                    + (self.get_center() - inter)
                    / np.linalg.norm(self.get_center() - inter)
                    * radius
                    * dot_distance
                )
                right_dot.move_to(dot_anchor)