G.405 find two medial segments commensurable in square only — Code

X.31

Find two medial segments commensurable in square only, containing a rational rectangle, and such that the square on the greater is greater than the square on the less by the square on a segment commensurable in length with the greater.
A B C D
"""Programmatic construction for Book X, Proposition 31 (X.31)."""

        from __future__ import annotations

        from geometor.model import Model


        def construct_g1() -> Model:
            """Construct the figure 0073.g1 using geometor.model."""
            model = Model("X.31")

            # Vertical straight line segments A, B, C, D
            A_t = model.set_point(24.0, -13.0, classes=["given"], ID="A")
            A_b = model.set_point(24.0, -142.0, ID="A_b")

            B_t = model.set_point(54.5, -54.0, classes=["given"], ID="B")
            B_b = model.set_point(54.5, -142.0, ID="B_b")

            C_t = model.set_point(81.5, -33.0, ID="C")
            C_b = model.set_point(81.5, -139.0, ID="C_b")

            D_t = model.set_point(111.0, -74.0, ID="D")
            D_b = model.set_point(111.0, -141.0, ID="D_b")

            for p_t, p_b in [(A_t, A_b), (B_t, B_b), (C_t, C_b), (D_t, D_b)]:
                model.construct_line(p_t, p_b)
                model.set_segment(p_t, p_b)

            return model


        if __name__ == "__main__":
            construct_g1()