A straight beam 37.4 mm long rocks about a fixed pivot placed exactly at its middle. Set up coordinates with that pivot at the origin Z. The two ends of the beam are E1 and E2. One end, E1, is connected by a rod 16.6 mm long down to a block whose centre is K; the block slides on a straight vertical rail 22.8 mm to the left of the pivot, and it hangs below the beam end it is connected to. Arrange the beam so that the other end, E2, sits 8.6 mm above the height of the pivot and lies on the right of it.

"""Walking beam rocking about its midpoint

Oracle formalization for mech_t2_mech_walking_beam_0077. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(36)

Z, E1, E2, K = scene.add.points(["Z", "E1", "E2", "K"])

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, the fixed pivot of the beam (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, the fixed pivot of the beam (y)")
scene.relate.is_midpoint(Z, scene.add.line_segment(E1, E2))
scene.constraint.eq(E1.distance(E2), 37.4, description="the beam is 37.4 long overall")
scene.constraint.eq(E2.y - Z.y, 8.6, description="the far end E2 sits 8.6 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="the far end E2 is on the right of the pivot")
scene.constraint.eq(K.x - Z.x, -22.8, description="the block runs on a straight rail 22.8 to the left of the pivot")
scene.constraint.eq(E1.distance(K), 16.6, description="the rod from the beam end E1 down to the block is 16.6 long")
scene.constraint.lt(K.y - E1.y, -0.05, description="the block hangs below the beam end it is connected to")


A straight beam 30.8 mm long rocks about a fixed pivot placed exactly at its middle. Set up coordinates with that pivot at the origin Z. The two ends of the beam are E1 and E2. One end, E1, is connected by a rod 20.2 mm long down to a block whose centre is K; the block slides on a straight vertical rail 27 mm to the left of the pivot, and it hangs below the beam end it is connected to. Arrange the beam so that the other end, E2, sits 8 mm above the height of the pivot and lies on the right of it.

Report every point as [x, y] in the datum frame described in the text, and every circle as {centre_label: radius}. Give at least 4 decimal places: a stated fact counts as satisfied only when its residual is below 5e-3 mm.

"""Walking beam rocking about its midpoint

Oracle formalization for mech_t2_mech_walking_beam_0078. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(40)

Z, E1, E2, K = scene.add.points(["Z", "E1", "E2", "K"])

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, the fixed pivot of the beam (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, the fixed pivot of the beam (y)")
scene.relate.is_midpoint(Z, scene.add.line_segment(E1, E2))
scene.constraint.eq(E1.distance(E2), 30.8, description="the beam is 30.8 long overall")
scene.constraint.eq(E2.y - Z.y, 8, description="the far end E2 sits 8 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="the far end E2 is on the right of the pivot")
scene.constraint.eq(K.x - Z.x, -27, description="the block runs on a straight rail 27 to the left of the pivot")
scene.constraint.eq(E1.distance(K), 20.2, description="the rod from the beam end E1 down to the block is 20.2 long")
scene.constraint.lt(K.y - E1.y, -0.05, description="the block hangs below the beam end it is connected to")

the pivot is at the middle, so each end is half the beam length away from it

the two ends are diametrically opposite about the pivot: whatever offset one end has, the other has the exact opposite

so if E2 is dy above the pivot then E1 is dy BELOW it, and their x-offsets are opposite too

the block is where a circle of the rod length centred at E1 cuts the rail line

E2 is on the right of the pivot, fixing which way the beam is tilted

the block hangs below E1, picking one of the two crossings with the rail


A straight beam 30.9 mm long rocks about a fixed pivot placed exactly at its middle. Set up coordinates with that pivot at the origin Z. The two ends of the beam are E1 and E2. One end, E1, is connected by a rod 16.3 mm long down to a block whose centre is K; the block slides on a straight vertical rail 20.5 mm to the left of the pivot, and it hangs below the beam end it is connected to. Arrange the beam so that the other end, E2, sits 7.6 mm above the height of the pivot and lies on the right of it.

"""Walking beam rocking about its midpoint

Oracle formalization for mech_t2_mech_walking_beam_0079. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(34)

Z, E1, E2, K = scene.add.points(["Z", "E1", "E2", "K"])

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, the fixed pivot of the beam (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, the fixed pivot of the beam (y)")
scene.relate.is_midpoint(Z, scene.add.line_segment(E1, E2))
scene.constraint.eq(E1.distance(E2), 30.9, description="the beam is 30.9 long overall")
scene.constraint.eq(E2.y - Z.y, 7.6, description="the far end E2 sits 7.6 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="the far end E2 is on the right of the pivot")
scene.constraint.eq(K.x - Z.x, -20.5, description="the block runs on a straight rail 20.5 to the left of the pivot")
scene.constraint.eq(E1.distance(K), 16.3, description="the rod from the beam end E1 down to the block is 16.3 long")
scene.constraint.lt(K.y - E1.y, -0.05, description="the block hangs below the beam end it is connected to")


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 24 mm to its right. Bar 2 is 14.5 mm long and bar 3 is 19.6315 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (17.6852, 18.5506), C2 at (12.7465, 21.7798) and C3 at (6.9531, 22.8999), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0001. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(53)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 17.6852, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 18.5506, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 12.7465, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 21.7798, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, 6.9531, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 22.8999, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 24, description="the fixed pin B is 24 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 14.5, description="bar BD is 14.5 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 14.5, description="bar BD is 14.5 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 14.5, description="bar BD is 14.5 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 19.6315, description="the connecting bar CD is 19.6315 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 19.6315, description="the connecting bar CD is 19.6315 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 19.6315, description="the connecting bar CD is 19.6315 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")

bar 1 turns about the FIXED pin A, so the distance AC cannot change

therefore the three required positions of C all lie on one circle centred at A

so A is the CIRCUMCENTRE of C1, C2, C3 and bar 1's length is that circumradius

likewise D always lies on a circle of radius |BD| centred at B

the three positions must share one set of bar lengths - they are three poses of the same mechanism

in each pose D is on the stated side of the line CB, which picks one of the two assemblies


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 21.3 mm to its right. Bar 2 is 16.3 mm long and bar 3 is 14.2472 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (18.1529, 19.5684), C2 at (10.8607, 23.7195) and C3 at (2.4761, 24.0457), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0002. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(47)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 18.1529, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 19.5684, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 10.8607, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 23.7195, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, 2.4761, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 24.0457, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 21.3, description="the fixed pin B is 21.3 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 16.3, description="bar BD is 16.3 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 16.3, description="bar BD is 16.3 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 16.3, description="bar BD is 16.3 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 14.2472, description="the connecting bar CD is 14.2472 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 14.2472, description="the connecting bar CD is 14.2472 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 14.2472, description="the connecting bar CD is 14.2472 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 19.4 mm to its right. Bar 2 is 13.4 mm long and bar 3 is 20.2128 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (15.1774, 21.7525), C2 at (6.6341, 23.9958) and C3 at (-1.7976, 21.3642), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0003. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(51)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 15.1774, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 21.7525, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 6.6341, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 23.9958, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, -1.7976, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 21.3642, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 19.4, description="the fixed pin B is 19.4 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 13.4, description="bar BD is 13.4 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 13.4, description="bar BD is 13.4 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 13.4, description="bar BD is 13.4 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 20.2128, description="the connecting bar CD is 20.2128 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 20.2128, description="the connecting bar CD is 20.2128 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 20.2128, description="the connecting bar CD is 20.2128 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 25.3 mm to its right. Bar 2 is 14 mm long and bar 3 is 21.4652 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (19.1686, 13.2059), C2 at (13.7589, 17.7673) and C3 at (6.8498, 19.2959), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0004. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(58)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 19.1686, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 13.2059, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 13.7589, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 17.7673, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, 6.8498, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 19.2959, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 25.3, description="the fixed pin B is 25.3 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 14, description="bar BD is 14 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 14, description="bar BD is 14 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 14, description="bar BD is 14 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 21.4652, description="the connecting bar CD is 21.4652 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 21.4652, description="the connecting bar CD is 21.4652 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 21.4652, description="the connecting bar CD is 21.4652 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 20.7 mm to its right. Bar 2 is 12.2 mm long and bar 3 is 16.4874 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (19.1496, 18.2329), C2 at (13.4335, 22.2335) and C3 at (6.6121, 23.6987), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0005. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(51)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 19.1496, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 18.2329, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 13.4335, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 22.2335, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, 6.6121, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 23.6987, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 20.7, description="the fixed pin B is 20.7 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 12.2, description="bar BD is 12.2 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 12.2, description="bar BD is 12.2 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 12.2, description="bar BD is 12.2 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 16.4874, description="the connecting bar CD is 16.4874 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 16.4874, description="the connecting bar CD is 16.4874 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 16.4874, description="the connecting bar CD is 16.4874 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 27.8 mm to its right. Bar 2 is 11.7 mm long and bar 3 is 26.0514 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (19.0025, 19.1887), C2 at (13.3624, 21.6984) and C3 at (7.192, 21.886), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0006. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(63)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 19.0025, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 19.1887, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 13.3624, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 21.6984, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, 7.192, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 21.886, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 27.8, description="the fixed pin B is 27.8 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 11.7, description="bar BD is 11.7 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 11.7, description="bar BD is 11.7 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 11.7, description="bar BD is 11.7 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 26.0514, description="the connecting bar CD is 26.0514 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 26.0514, description="the connecting bar CD is 26.0514 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 26.0514, description="the connecting bar CD is 26.0514 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 26.2 mm to its right. Bar 2 is 17.6 mm long and bar 3 is 20.5739 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (20.0161, 13.5466), C2 at (15.3901, 17.228) and C3 at (9.6836, 18.7732), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0007. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(56)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 20.0161, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 13.5466, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 15.3901, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 17.228, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, 9.6836, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 18.7732, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 26.2, description="the fixed pin B is 26.2 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 17.6, description="bar BD is 17.6 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 17.6, description="bar BD is 17.6 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 17.6, description="bar BD is 17.6 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 20.5739, description="the connecting bar CD is 20.5739 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 20.5739, description="the connecting bar CD is 20.5739 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 20.5739, description="the connecting bar CD is 20.5739 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")


A mechanism is built from three rigid bars pinned together in the plane. Bar 1 turns about a fixed pin A on the bench and carries a moving pin C at its far end. Bar 2 turns about a second fixed pin B and carries a moving pin D at its far end. Bar 3 joins pin C to pin D. The bars are rigid, so no bar changes length as the mechanism moves, and the two fixed pins never move. The fixed pin B sits at the same height as A and 26.1 mm to its right. Bar 2 is 17.2 mm long and bar 3 is 26.4432 mm long. As the mechanism is worked, pin C has to pass through three required positions in turn: C1 at (18.4183, 22.5027), C2 at (9.1016, 26.6292) and C3 at (-0.9824, 25.1651), measured on the bench grid. Write down where the fixed pin A must be placed, and where pin D sits in each of the three positions - call those D1, D2 and D3. In every one of the three positions the pin D lies to the left of the straight line running from C to B.

"""Four-bar linkage through three required positions

Oracle formalization for mech_t3_mech_fourbar_three_positions_0008. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(63)

A, B, C1, C2, C3, D1, D2, D3 = scene.add.points(["A", "B", "C1", "C2", "C3", "D1", "D2", "D3"])

scene.constraint.eq(C1.x, 18.4183, description="required position 1 of the moving pin C (x)")
scene.constraint.eq(C1.y, 22.5027, description="required position 1 of the moving pin C (y)")
scene.constraint.eq(C2.x, 9.1016, description="required position 2 of the moving pin C (x)")
scene.constraint.eq(C2.y, 26.6292, description="required position 2 of the moving pin C (y)")
scene.constraint.eq(C3.x, -0.9824, description="required position 3 of the moving pin C (x)")
scene.constraint.eq(C3.y, 25.1651, description="required position 3 of the moving pin C (y)")
scene.constraint.eq(A.distance(C1), A.distance(C2), description="bar AC is rigid, so C is the same distance from A in positions 1 and 2")
scene.constraint.eq(A.distance(C1), A.distance(C3), description="bar AC is rigid, so C is the same distance from A in positions 1 and 3")
scene.constraint.eq(B.y, A.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.eq(B.x - A.x, 26.1, description="the fixed pin B is 26.1 to the right of the fixed pin A")
scene.constraint.eq(B.distance(D1), 17.2, description="bar BD is 17.2 long, the same in position 1 as in every other")
scene.constraint.eq(B.distance(D2), 17.2, description="bar BD is 17.2 long, the same in position 2 as in every other")
scene.constraint.eq(B.distance(D3), 17.2, description="bar BD is 17.2 long, the same in position 3 as in every other")
scene.constraint.eq(C1.distance(D1), 26.4432, description="the connecting bar CD is 26.4432 long, the same in position 1 as in every other")
scene.constraint.eq(C2.distance(D2), 26.4432, description="the connecting bar CD is 26.4432 long, the same in position 2 as in every other")
scene.constraint.eq(C3.distance(D3), 26.4432, description="the connecting bar CD is 26.4432 long, the same in position 3 as in every other")
scene.constraint.gt(cross(C1, B, D1), 0.05, description="in position 1 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C2, B, D2), 0.05, description="in position 2 the pin D lies to the left of the line from C to B")
scene.constraint.gt(cross(C3, B, D3), 0.05, description="in position 3 the pin D lies to the left of the line from C to B")


A quick-return drive works like this. A crank 10.6 mm long turns about a fixed centre O; set up coordinates with O at the origin and mark the datum direction with a construction point E, 10 mm from O and level with it. The crank pin at its far end is P. A long lever is pivoted to the bench at S, directly below O and 16.4 mm down from it. The lever has a straight slot cut along it, and the crank pin P slides in that slot, so P always sits somewhere along the lever between the pivot S and the lever's tip T. The lever measures 31.5 mm from S to T. A connecting rod 13.4 mm long runs from the tip T to a block whose centre is R, sliding on a straight rail at height 15.8; the block lies to the right of the lever tip. Show the arrangement at the moment when the crank stands 40 degrees round from the datum direction, turned anticlockwise.

"""Quick-return drive with a slotted lever

Oracle formalization for mech_t3_mech_quick_return_0080. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(36)

O, E, P, S, T, R = scene.add.points(["O", "E", "P", "S", "T", "R"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the crank centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the crank centre (y)")
scene.constraint.eq(E.y, O.y, description="construction point E is level with O")
scene.constraint.eq(E.x - O.x, 10, description="construction point E is 10 mm from O in the datum direction, so the crank angle can be measured")
scene.constraint.eq(O.distance(P), 10.6, description="the crank OP is 10.6 long")
scene.constraint.eq(scene.add.angle(P, O, E).value, 40, description="the crank stands 40 degrees round from the datum direction")
scene.constraint.gt(cross(O, E, P), 0.05, description="the crank is turned anticlockwise from the datum direction")
scene.constraint.eq(S.x, O.x, description="the lever pivot S is directly below the crank centre")
scene.constraint.eq(O.y - S.y, 16.4, description="the lever pivot S is 16.4 below the crank centre")
scene.constraint.eq(S.distance(T), 31.5, description="the slotted lever is 31.5 long from its pivot S to its tip T")
scene.relate.point_lies_on(P, scene.add.line_segment(S, T))
scene.constraint.eq(T.distance(R), 13.4, description="the connecting rod from the lever tip to the block is 13.4 long")
scene.constraint.eq(R.y, 15.8, description="the block runs on a straight rail at height 15.8")
scene.constraint.gt(R.x - T.x, 0.05, description="the block lies to the right of the lever tip")

the crank pin position follows from the crank length and the stated angle

'slides in the slot' means S, P and T are collinear, with P between S and T

so the lever's direction is set by the line from S through P, and T is that far along it

the block is where a circle of the rod length centred at T cuts the rail line

the block is to the right of the tip, picking one of the two crossings


A quick-return drive works like this. A crank 10.1 mm long turns about a fixed centre O; set up coordinates with O at the origin and mark the datum direction with a construction point E, 10 mm from O and level with it. The crank pin at its far end is P. A long lever is pivoted to the bench at S, directly below O and 19.9 mm down from it. The lever has a straight slot cut along it, and the crank pin P slides in that slot, so P always sits somewhere along the lever between the pivot S and the lever's tip T. The lever measures 40.9 mm from S to T. A connecting rod 11.8 mm long runs from the tip T to a block whose centre is R, sliding on a straight rail at height 27.9; the block lies to the right of the lever tip. Show the arrangement at the moment when the crank stands 130 degrees round from the datum direction, turned anticlockwise.

"""Quick-return drive with a slotted lever

Oracle formalization for mech_t3_mech_quick_return_0081. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(41)

O, E, P, S, T, R = scene.add.points(["O", "E", "P", "S", "T", "R"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the crank centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the crank centre (y)")
scene.constraint.eq(E.y, O.y, description="construction point E is level with O")
scene.constraint.eq(E.x - O.x, 10, description="construction point E is 10 mm from O in the datum direction, so the crank angle can be measured")
scene.constraint.eq(O.distance(P), 10.1, description="the crank OP is 10.1 long")
scene.constraint.eq(scene.add.angle(P, O, E).value, 130, description="the crank stands 130 degrees round from the datum direction")
scene.constraint.gt(cross(O, E, P), 0.05, description="the crank is turned anticlockwise from the datum direction")
scene.constraint.eq(S.x, O.x, description="the lever pivot S is directly below the crank centre")
scene.constraint.eq(O.y - S.y, 19.9, description="the lever pivot S is 19.9 below the crank centre")
scene.constraint.eq(S.distance(T), 40.9, description="the slotted lever is 40.9 long from its pivot S to its tip T")
scene.relate.point_lies_on(P, scene.add.line_segment(S, T))
scene.constraint.eq(T.distance(R), 11.8, description="the connecting rod from the lever tip to the block is 11.8 long")
scene.constraint.eq(R.y, 27.9, description="the block runs on a straight rail at height 27.9")
scene.constraint.gt(R.x - T.x, 0.05, description="the block lies to the right of the lever tip")


A quick-return drive works like this. A crank 11.8 mm long turns about a fixed centre O; set up coordinates with O at the origin and mark the datum direction with a construction point E, 10 mm from O and level with it. The crank pin at its far end is P. A long lever is pivoted to the bench at S, directly below O and 14.8 mm down from it. The lever has a straight slot cut along it, and the crank pin P slides in that slot, so P always sits somewhere along the lever between the pivot S and the lever's tip T. The lever measures 34.5 mm from S to T. A connecting rod 10.8 mm long runs from the tip T to a block whose centre is R, sliding on a straight rail at height 26.4; the block lies to the right of the lever tip. Show the arrangement at the moment when the crank stands 55 degrees round from the datum direction, turned anticlockwise.

"""Quick-return drive with a slotted lever

Oracle formalization for mech_t3_mech_quick_return_0082. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(39)

O, E, P, S, T, R = scene.add.points(["O", "E", "P", "S", "T", "R"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the crank centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the crank centre (y)")
scene.constraint.eq(E.y, O.y, description="construction point E is level with O")
scene.constraint.eq(E.x - O.x, 10, description="construction point E is 10 mm from O in the datum direction, so the crank angle can be measured")
scene.constraint.eq(O.distance(P), 11.8, description="the crank OP is 11.8 long")
scene.constraint.eq(scene.add.angle(P, O, E).value, 55, description="the crank stands 55 degrees round from the datum direction")
scene.constraint.gt(cross(O, E, P), 0.05, description="the crank is turned anticlockwise from the datum direction")
scene.constraint.eq(S.x, O.x, description="the lever pivot S is directly below the crank centre")
scene.constraint.eq(O.y - S.y, 14.8, description="the lever pivot S is 14.8 below the crank centre")
scene.constraint.eq(S.distance(T), 34.5, description="the slotted lever is 34.5 long from its pivot S to its tip T")
scene.relate.point_lies_on(P, scene.add.line_segment(S, T))
scene.constraint.eq(T.distance(R), 10.8, description="the connecting rod from the lever tip to the block is 10.8 long")
scene.constraint.eq(R.y, 26.4, description="the block runs on a straight rail at height 26.4")
scene.constraint.gt(R.x - T.x, 0.05, description="the block lies to the right of the lever tip")


A quick-return drive works like this. A crank 11.8 mm long turns about a fixed centre O; set up coordinates with O at the origin and mark the datum direction with a construction point E, 10 mm from O and level with it. The crank pin at its far end is P. A long lever is pivoted to the bench at S, directly below O and 20.1 mm down from it. The lever has a straight slot cut along it, and the crank pin P slides in that slot, so P always sits somewhere along the lever between the pivot S and the lever's tip T. The lever measures 34.6 mm from S to T. A connecting rod 18.2 mm long runs from the tip T to a block whose centre is R, sliding on a straight rail at height 16.8; the block lies to the right of the lever tip. Show the arrangement at the moment when the crank stands 130 degrees round from the datum direction, turned anticlockwise.

"""Quick-return drive with a slotted lever

Oracle formalization for mech_t3_mech_quick_return_0083. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(31)

O, E, P, S, T, R = scene.add.points(["O", "E", "P", "S", "T", "R"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the crank centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the crank centre (y)")
scene.constraint.eq(E.y, O.y, description="construction point E is level with O")
scene.constraint.eq(E.x - O.x, 10, description="construction point E is 10 mm from O in the datum direction, so the crank angle can be measured")
scene.constraint.eq(O.distance(P), 11.8, description="the crank OP is 11.8 long")
scene.constraint.eq(scene.add.angle(P, O, E).value, 130, description="the crank stands 130 degrees round from the datum direction")
scene.constraint.gt(cross(O, E, P), 0.05, description="the crank is turned anticlockwise from the datum direction")
scene.constraint.eq(S.x, O.x, description="the lever pivot S is directly below the crank centre")
scene.constraint.eq(O.y - S.y, 20.1, description="the lever pivot S is 20.1 below the crank centre")
scene.constraint.eq(S.distance(T), 34.6, description="the slotted lever is 34.6 long from its pivot S to its tip T")
scene.relate.point_lies_on(P, scene.add.line_segment(S, T))
scene.constraint.eq(T.distance(R), 18.2, description="the connecting rod from the lever tip to the block is 18.2 long")
scene.constraint.eq(R.y, 16.8, description="the block runs on a straight rail at height 16.8")
scene.constraint.gt(R.x - T.x, 0.05, description="the block lies to the right of the lever tip")


A quick-return drive works like this. A crank 9.1 mm long turns about a fixed centre O; set up coordinates with O at the origin and mark the datum direction with a construction point E, 10 mm from O and level with it. The crank pin at its far end is P. A long lever is pivoted to the bench at S, directly below O and 14.9 mm down from it. The lever has a straight slot cut along it, and the crank pin P slides in that slot, so P always sits somewhere along the lever between the pivot S and the lever's tip T. The lever measures 34.2 mm from S to T. A connecting rod 12 mm long runs from the tip T to a block whose centre is R, sliding on a straight rail at height 22.3; the block lies to the right of the lever tip. Show the arrangement at the moment when the crank stands 130 degrees round from the datum direction, turned anticlockwise.

"""Quick-return drive with a slotted lever

Oracle formalization for mech_t3_mech_quick_return_0084. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(34)

O, E, P, S, T, R = scene.add.points(["O", "E", "P", "S", "T", "R"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the crank centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the crank centre (y)")
scene.constraint.eq(E.y, O.y, description="construction point E is level with O")
scene.constraint.eq(E.x - O.x, 10, description="construction point E is 10 mm from O in the datum direction, so the crank angle can be measured")
scene.constraint.eq(O.distance(P), 9.1, description="the crank OP is 9.1 long")
scene.constraint.eq(scene.add.angle(P, O, E).value, 130, description="the crank stands 130 degrees round from the datum direction")
scene.constraint.gt(cross(O, E, P), 0.05, description="the crank is turned anticlockwise from the datum direction")
scene.constraint.eq(S.x, O.x, description="the lever pivot S is directly below the crank centre")
scene.constraint.eq(O.y - S.y, 14.9, description="the lever pivot S is 14.9 below the crank centre")
scene.constraint.eq(S.distance(T), 34.2, description="the slotted lever is 34.2 long from its pivot S to its tip T")
scene.relate.point_lies_on(P, scene.add.line_segment(S, T))
scene.constraint.eq(T.distance(R), 12, description="the connecting rod from the lever tip to the block is 12 long")
scene.constraint.eq(R.y, 22.3, description="the block runs on a straight rail at height 22.3")
scene.constraint.gt(R.x - T.x, 0.05, description="the block lies to the right of the lever tip")


A quick-return drive works like this. A crank 10.2 mm long turns about a fixed centre O; set up coordinates with O at the origin and mark the datum direction with a construction point E, 10 mm from O and level with it. The crank pin at its far end is P. A long lever is pivoted to the bench at S, directly below O and 16.9 mm down from it. The lever has a straight slot cut along it, and the crank pin P slides in that slot, so P always sits somewhere along the lever between the pivot S and the lever's tip T. The lever measures 31.6 mm from S to T. A connecting rod 11 mm long runs from the tip T to a block whose centre is R, sliding on a straight rail at height 19.1; the block lies to the right of the lever tip. Show the arrangement at the moment when the crank stands 115 degrees round from the datum direction, turned anticlockwise.

"""Quick-return drive with a slotted lever

Oracle formalization for mech_t3_mech_quick_return_0085. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(30)

O, E, P, S, T, R = scene.add.points(["O", "E", "P", "S", "T", "R"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the crank centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the crank centre (y)")
scene.constraint.eq(E.y, O.y, description="construction point E is level with O")
scene.constraint.eq(E.x - O.x, 10, description="construction point E is 10 mm from O in the datum direction, so the crank angle can be measured")
scene.constraint.eq(O.distance(P), 10.2, description="the crank OP is 10.2 long")
scene.constraint.eq(scene.add.angle(P, O, E).value, 115, description="the crank stands 115 degrees round from the datum direction")
scene.constraint.gt(cross(O, E, P), 0.05, description="the crank is turned anticlockwise from the datum direction")
scene.constraint.eq(S.x, O.x, description="the lever pivot S is directly below the crank centre")
scene.constraint.eq(O.y - S.y, 16.9, description="the lever pivot S is 16.9 below the crank centre")
scene.constraint.eq(S.distance(T), 31.6, description="the slotted lever is 31.6 long from its pivot S to its tip T")
scene.relate.point_lies_on(P, scene.add.line_segment(S, T))
scene.constraint.eq(T.distance(R), 11, description="the connecting rod from the lever tip to the block is 11 long")
scene.constraint.eq(R.y, 19.1, description="the block runs on a straight rail at height 19.1")
scene.constraint.gt(R.x - T.x, 0.05, description="the block lies to the right of the lever tip")


A quick-return drive works like this. A crank 8.4 mm long turns about a fixed centre O; set up coordinates with O at the origin and mark the datum direction with a construction point E, 10 mm from O and level with it. The crank pin at its far end is P. A long lever is pivoted to the bench at S, directly below O and 19.6 mm down from it. The lever has a straight slot cut along it, and the crank pin P slides in that slot, so P always sits somewhere along the lever between the pivot S and the lever's tip T. The lever measures 41.3 mm from S to T. A connecting rod 14.6 mm long runs from the tip T to a block whose centre is R, sliding on a straight rail at height 26.4; the block lies to the right of the lever tip. Show the arrangement at the moment when the crank stands 100 degrees round from the datum direction, turned anticlockwise.

"""Quick-return drive with a slotted lever

Oracle formalization for mech_t3_mech_quick_return_0086. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(39)

O, E, P, S, T, R = scene.add.points(["O", "E", "P", "S", "T", "R"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the crank centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the crank centre (y)")
scene.constraint.eq(E.y, O.y, description="construction point E is level with O")
scene.constraint.eq(E.x - O.x, 10, description="construction point E is 10 mm from O in the datum direction, so the crank angle can be measured")
scene.constraint.eq(O.distance(P), 8.4, description="the crank OP is 8.4 long")
scene.constraint.eq(scene.add.angle(P, O, E).value, 100, description="the crank stands 100 degrees round from the datum direction")
scene.constraint.gt(cross(O, E, P), 0.05, description="the crank is turned anticlockwise from the datum direction")
scene.constraint.eq(S.x, O.x, description="the lever pivot S is directly below the crank centre")
scene.constraint.eq(O.y - S.y, 19.6, description="the lever pivot S is 19.6 below the crank centre")
scene.constraint.eq(S.distance(T), 41.3, description="the slotted lever is 41.3 long from its pivot S to its tip T")
scene.relate.point_lies_on(P, scene.add.line_segment(S, T))
scene.constraint.eq(T.distance(R), 14.6, description="the connecting rod from the lever tip to the block is 14.6 long")
scene.constraint.eq(R.y, 26.4, description="the block runs on a straight rail at height 26.4")
scene.constraint.gt(R.x - T.x, 0.05, description="the block lies to the right of the lever tip")


A four-bar mechanism has two fixed pins, O1 and O2, sitting at the same height 20.5 mm apart. Set up coordinates with O1 at the origin and O2 to its right. A crank 8.2 mm long turns about O1; a connecting bar 23 mm long runs from the end of the crank to the end of an output bar; the output bar is 19.3 mm long and turns about O2. The mechanism is to be shown in its two dead positions - the two positions at which the crank and the connecting bar lie in one straight line, so that turning the output bar can no longer drive the crank round. In the first of these the crank and connecting bar are stretched out end to end, with the crank end pin A1 lying between O1 and the output pin B1. In the second they are folded back on each other, with the fixed pin O1 lying between the crank end pin A2 and the output pin B2. In both positions the output pin is above the line joining the two fixed pins.

"""Four-bar at its two dead positions

Oracle formalization for mech_t3_mech_toggle_positions_0094. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(37)

O1, O2, A1, B1, A2, B2 = scene.add.points(["O1", "O2", "A1", "B1", "A2", "B2"])

scene.constraint.eq(O1.x, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (x)")
scene.constraint.eq(O1.y, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (y)")
scene.constraint.eq(O2.y, O1.y, description="the two fixed pins sit at the same height")
scene.constraint.gt(O2.x - O1.x, 1.0, description="datum: O2 is to the right of O1")
scene.constraint.eq(O1.distance(O2), 20.5, description="the two fixed pins are 20.5 apart")
scene.constraint.eq(O1.distance(A1), 8.2, description="the crank is 8.2 long (first position)")
scene.constraint.eq(A1.distance(B1), 23, description="the connecting bar is 23 long (first position)")
scene.constraint.eq(O2.distance(B1), 19.3, description="the output bar is 19.3 long (first position)")
scene.relate.point_lies_on(A1, scene.add.line_segment(O1, B1))
scene.constraint.eq(O1.distance(A2), 8.2, description="the crank is 8.2 long (second position)")
scene.constraint.eq(A2.distance(B2), 23, description="the connecting bar is 23 long (second position)")
scene.constraint.eq(O2.distance(B2), 19.3, description="the output bar is 19.3 long (second position)")
scene.relate.point_lies_on(O1, scene.add.line_segment(A2, B2))
scene.constraint.gt(cross(O1, O2, B1), 0.05, description="in the first position the output pin is above the line of fixed pins")
scene.constraint.gt(cross(O1, O2, B2), 0.05, description="in the second position the output pin is above the line of fixed pins")

a dead position is where the crank and the connecting bar become collinear

stretched out, the distance from O1 to the output pin is crank + connecting bar

folded back, that distance is connecting bar - crank

in each case the output pin is then where a circle about O1 of that radius cuts a circle about O2 of the output-bar length

the crank end pin then sits on the same straight line, at the crank length from O1

in both positions the output pin is above the line of fixed pins, which picks one of the two crossings


A four-bar mechanism has two fixed pins, O1 and O2, sitting at the same height 19.4 mm apart. Set up coordinates with O1 at the origin and O2 to its right. A crank 6.6 mm long turns about O1; a connecting bar 19.1 mm long runs from the end of the crank to the end of an output bar; the output bar is 21.1 mm long and turns about O2. The mechanism is to be shown in its two dead positions - the two positions at which the crank and the connecting bar lie in one straight line, so that turning the output bar can no longer drive the crank round. In the first of these the crank and connecting bar are stretched out end to end, with the crank end pin A1 lying between O1 and the output pin B1. In the second they are folded back on each other, with the fixed pin O1 lying between the crank end pin A2 and the output pin B2. In both positions the output pin is above the line joining the two fixed pins.

"""Four-bar at its two dead positions

Oracle formalization for mech_t3_mech_toggle_positions_0095. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(32)

O1, O2, A1, B1, A2, B2 = scene.add.points(["O1", "O2", "A1", "B1", "A2", "B2"])

scene.constraint.eq(O1.x, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (x)")
scene.constraint.eq(O1.y, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (y)")
scene.constraint.eq(O2.y, O1.y, description="the two fixed pins sit at the same height")
scene.constraint.gt(O2.x - O1.x, 1.0, description="datum: O2 is to the right of O1")
scene.constraint.eq(O1.distance(O2), 19.4, description="the two fixed pins are 19.4 apart")
scene.constraint.eq(O1.distance(A1), 6.6, description="the crank is 6.6 long (first position)")
scene.constraint.eq(A1.distance(B1), 19.1, description="the connecting bar is 19.1 long (first position)")
scene.constraint.eq(O2.distance(B1), 21.1, description="the output bar is 21.1 long (first position)")
scene.relate.point_lies_on(A1, scene.add.line_segment(O1, B1))
scene.constraint.eq(O1.distance(A2), 6.6, description="the crank is 6.6 long (second position)")
scene.constraint.eq(A2.distance(B2), 19.1, description="the connecting bar is 19.1 long (second position)")
scene.constraint.eq(O2.distance(B2), 21.1, description="the output bar is 21.1 long (second position)")
scene.relate.point_lies_on(O1, scene.add.line_segment(A2, B2))
scene.constraint.gt(cross(O1, O2, B1), 0.05, description="in the first position the output pin is above the line of fixed pins")
scene.constraint.gt(cross(O1, O2, B2), 0.05, description="in the second position the output pin is above the line of fixed pins")


A four-bar mechanism has two fixed pins, O1 and O2, sitting at the same height 22.1 mm apart. Set up coordinates with O1 at the origin and O2 to its right. A crank 7.5 mm long turns about O1; a connecting bar 21.2 mm long runs from the end of the crank to the end of an output bar; the output bar is 20.6 mm long and turns about O2. The mechanism is to be shown in its two dead positions - the two positions at which the crank and the connecting bar lie in one straight line, so that turning the output bar can no longer drive the crank round. In the first of these the crank and connecting bar are stretched out end to end, with the crank end pin A1 lying between O1 and the output pin B1. In the second they are folded back on each other, with the fixed pin O1 lying between the crank end pin A2 and the output pin B2. In both positions the output pin is above the line joining the two fixed pins.

"""Four-bar at its two dead positions

Oracle formalization for mech_t3_mech_toggle_positions_0096. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(34)

O1, O2, A1, B1, A2, B2 = scene.add.points(["O1", "O2", "A1", "B1", "A2", "B2"])

scene.constraint.eq(O1.x, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (x)")
scene.constraint.eq(O1.y, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (y)")
scene.constraint.eq(O2.y, O1.y, description="the two fixed pins sit at the same height")
scene.constraint.gt(O2.x - O1.x, 1.0, description="datum: O2 is to the right of O1")
scene.constraint.eq(O1.distance(O2), 22.1, description="the two fixed pins are 22.1 apart")
scene.constraint.eq(O1.distance(A1), 7.5, description="the crank is 7.5 long (first position)")
scene.constraint.eq(A1.distance(B1), 21.2, description="the connecting bar is 21.2 long (first position)")
scene.constraint.eq(O2.distance(B1), 20.6, description="the output bar is 20.6 long (first position)")
scene.relate.point_lies_on(A1, scene.add.line_segment(O1, B1))
scene.constraint.eq(O1.distance(A2), 7.5, description="the crank is 7.5 long (second position)")
scene.constraint.eq(A2.distance(B2), 21.2, description="the connecting bar is 21.2 long (second position)")
scene.constraint.eq(O2.distance(B2), 20.6, description="the output bar is 20.6 long (second position)")
scene.relate.point_lies_on(O1, scene.add.line_segment(A2, B2))
scene.constraint.gt(cross(O1, O2, B1), 0.05, description="in the first position the output pin is above the line of fixed pins")
scene.constraint.gt(cross(O1, O2, B2), 0.05, description="in the second position the output pin is above the line of fixed pins")


A four-bar mechanism has two fixed pins, O1 and O2, sitting at the same height 23.2 mm apart. Set up coordinates with O1 at the origin and O2 to its right. A crank 5.2 mm long turns about O1; a connecting bar 19.6 mm long runs from the end of the crank to the end of an output bar; the output bar is 12.6 mm long and turns about O2. The mechanism is to be shown in its two dead positions - the two positions at which the crank and the connecting bar lie in one straight line, so that turning the output bar can no longer drive the crank round. In the first of these the crank and connecting bar are stretched out end to end, with the crank end pin A1 lying between O1 and the output pin B1. In the second they are folded back on each other, with the fixed pin O1 lying between the crank end pin A2 and the output pin B2. In both positions the output pin is above the line joining the two fixed pins.

"""Four-bar at its two dead positions

Oracle formalization for mech_t3_mech_toggle_positions_0097. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(35)

O1, O2, A1, B1, A2, B2 = scene.add.points(["O1", "O2", "A1", "B1", "A2", "B2"])

scene.constraint.eq(O1.x, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (x)")
scene.constraint.eq(O1.y, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (y)")
scene.constraint.eq(O2.y, O1.y, description="the two fixed pins sit at the same height")
scene.constraint.gt(O2.x - O1.x, 1.0, description="datum: O2 is to the right of O1")
scene.constraint.eq(O1.distance(O2), 23.2, description="the two fixed pins are 23.2 apart")
scene.constraint.eq(O1.distance(A1), 5.2, description="the crank is 5.2 long (first position)")
scene.constraint.eq(A1.distance(B1), 19.6, description="the connecting bar is 19.6 long (first position)")
scene.constraint.eq(O2.distance(B1), 12.6, description="the output bar is 12.6 long (first position)")
scene.relate.point_lies_on(A1, scene.add.line_segment(O1, B1))
scene.constraint.eq(O1.distance(A2), 5.2, description="the crank is 5.2 long (second position)")
scene.constraint.eq(A2.distance(B2), 19.6, description="the connecting bar is 19.6 long (second position)")
scene.constraint.eq(O2.distance(B2), 12.6, description="the output bar is 12.6 long (second position)")
scene.relate.point_lies_on(O1, scene.add.line_segment(A2, B2))
scene.constraint.gt(cross(O1, O2, B1), 0.05, description="in the first position the output pin is above the line of fixed pins")
scene.constraint.gt(cross(O1, O2, B2), 0.05, description="in the second position the output pin is above the line of fixed pins")


A four-bar mechanism has two fixed pins, O1 and O2, sitting at the same height 17.8 mm apart. Set up coordinates with O1 at the origin and O2 to its right. A crank 5.6 mm long turns about O1; a connecting bar 16.1 mm long runs from the end of the crank to the end of an output bar; the output bar is 19.7 mm long and turns about O2. The mechanism is to be shown in its two dead positions - the two positions at which the crank and the connecting bar lie in one straight line, so that turning the output bar can no longer drive the crank round. In the first of these the crank and connecting bar are stretched out end to end, with the crank end pin A1 lying between O1 and the output pin B1. In the second they are folded back on each other, with the fixed pin O1 lying between the crank end pin A2 and the output pin B2. In both positions the output pin is above the line joining the two fixed pins.

"""Four-bar at its two dead positions

Oracle formalization for mech_t3_mech_toggle_positions_0098. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(29)

O1, O2, A1, B1, A2, B2 = scene.add.points(["O1", "O2", "A1", "B1", "A2", "B2"])

scene.constraint.eq(O1.x, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (x)")
scene.constraint.eq(O1.y, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (y)")
scene.constraint.eq(O2.y, O1.y, description="the two fixed pins sit at the same height")
scene.constraint.gt(O2.x - O1.x, 1.0, description="datum: O2 is to the right of O1")
scene.constraint.eq(O1.distance(O2), 17.8, description="the two fixed pins are 17.8 apart")
scene.constraint.eq(O1.distance(A1), 5.6, description="the crank is 5.6 long (first position)")
scene.constraint.eq(A1.distance(B1), 16.1, description="the connecting bar is 16.1 long (first position)")
scene.constraint.eq(O2.distance(B1), 19.7, description="the output bar is 19.7 long (first position)")
scene.relate.point_lies_on(A1, scene.add.line_segment(O1, B1))
scene.constraint.eq(O1.distance(A2), 5.6, description="the crank is 5.6 long (second position)")
scene.constraint.eq(A2.distance(B2), 16.1, description="the connecting bar is 16.1 long (second position)")
scene.constraint.eq(O2.distance(B2), 19.7, description="the output bar is 19.7 long (second position)")
scene.relate.point_lies_on(O1, scene.add.line_segment(A2, B2))
scene.constraint.gt(cross(O1, O2, B1), 0.05, description="in the first position the output pin is above the line of fixed pins")
scene.constraint.gt(cross(O1, O2, B2), 0.05, description="in the second position the output pin is above the line of fixed pins")


A four-bar mechanism has two fixed pins, O1 and O2, sitting at the same height 23.3 mm apart. Set up coordinates with O1 at the origin and O2 to its right. A crank 7.1 mm long turns about O1; a connecting bar 18.2 mm long runs from the end of the crank to the end of an output bar; the output bar is 13.5 mm long and turns about O2. The mechanism is to be shown in its two dead positions - the two positions at which the crank and the connecting bar lie in one straight line, so that turning the output bar can no longer drive the crank round. In the first of these the crank and connecting bar are stretched out end to end, with the crank end pin A1 lying between O1 and the output pin B1. In the second they are folded back on each other, with the fixed pin O1 lying between the crank end pin A2 and the output pin B2. In both positions the output pin is above the line joining the two fixed pins.

"""Four-bar at its two dead positions

Oracle formalization for mech_t3_mech_toggle_positions_0099. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(35)

O1, O2, A1, B1, A2, B2 = scene.add.points(["O1", "O2", "A1", "B1", "A2", "B2"])

scene.constraint.eq(O1.x, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (x)")
scene.constraint.eq(O1.y, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (y)")
scene.constraint.eq(O2.y, O1.y, description="the two fixed pins sit at the same height")
scene.constraint.gt(O2.x - O1.x, 1.0, description="datum: O2 is to the right of O1")
scene.constraint.eq(O1.distance(O2), 23.3, description="the two fixed pins are 23.3 apart")
scene.constraint.eq(O1.distance(A1), 7.1, description="the crank is 7.1 long (first position)")
scene.constraint.eq(A1.distance(B1), 18.2, description="the connecting bar is 18.2 long (first position)")
scene.constraint.eq(O2.distance(B1), 13.5, description="the output bar is 13.5 long (first position)")
scene.relate.point_lies_on(A1, scene.add.line_segment(O1, B1))
scene.constraint.eq(O1.distance(A2), 7.1, description="the crank is 7.1 long (second position)")
scene.constraint.eq(A2.distance(B2), 18.2, description="the connecting bar is 18.2 long (second position)")
scene.constraint.eq(O2.distance(B2), 13.5, description="the output bar is 13.5 long (second position)")
scene.relate.point_lies_on(O1, scene.add.line_segment(A2, B2))
scene.constraint.gt(cross(O1, O2, B1), 0.05, description="in the first position the output pin is above the line of fixed pins")
scene.constraint.gt(cross(O1, O2, B2), 0.05, description="in the second position the output pin is above the line of fixed pins")


A four-bar mechanism has two fixed pins, O1 and O2, sitting at the same height 22.8 mm apart. Set up coordinates with O1 at the origin and O2 to its right. A crank 8.5 mm long turns about O1; a connecting bar 25.2 mm long runs from the end of the crank to the end of an output bar; the output bar is 15.6 mm long and turns about O2. The mechanism is to be shown in its two dead positions - the two positions at which the crank and the connecting bar lie in one straight line, so that turning the output bar can no longer drive the crank round. In the first of these the crank and connecting bar are stretched out end to end, with the crank end pin A1 lying between O1 and the output pin B1. In the second they are folded back on each other, with the fixed pin O1 lying between the crank end pin A2 and the output pin B2. In both positions the output pin is above the line joining the two fixed pins.

"""Four-bar at its two dead positions

Oracle formalization for mech_t3_mech_toggle_positions_0100. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(45)

O1, O2, A1, B1, A2, B2 = scene.add.points(["O1", "O2", "A1", "B1", "A2", "B2"])

scene.constraint.eq(O1.x, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (x)")
scene.constraint.eq(O1.y, 0, description="datum: O1 is the origin, the fixed pin the crank turns about (y)")
scene.constraint.eq(O2.y, O1.y, description="the two fixed pins sit at the same height")
scene.constraint.gt(O2.x - O1.x, 1.0, description="datum: O2 is to the right of O1")
scene.constraint.eq(O1.distance(O2), 22.8, description="the two fixed pins are 22.8 apart")
scene.constraint.eq(O1.distance(A1), 8.5, description="the crank is 8.5 long (first position)")
scene.constraint.eq(A1.distance(B1), 25.2, description="the connecting bar is 25.2 long (first position)")
scene.constraint.eq(O2.distance(B1), 15.6, description="the output bar is 15.6 long (first position)")
scene.relate.point_lies_on(A1, scene.add.line_segment(O1, B1))
scene.constraint.eq(O1.distance(A2), 8.5, description="the crank is 8.5 long (second position)")
scene.constraint.eq(A2.distance(B2), 25.2, description="the connecting bar is 25.2 long (second position)")
scene.constraint.eq(O2.distance(B2), 15.6, description="the output bar is 15.6 long (second position)")
scene.relate.point_lies_on(O1, scene.add.line_segment(A2, B2))
scene.constraint.gt(cross(O1, O2, B1), 0.05, description="in the first position the output pin is above the line of fixed pins")
scene.constraint.gt(cross(O1, O2, B2), 0.05, description="in the second position the output pin is above the line of fixed pins")


A bent lever turns about a fixed pin F. One arm runs 9.7 mm from F out to a pin H, the other runs 17.7 mm from F out to a pin G, and the two arms are set at a right angle to each other at F. A straight pull-rod connects pin G to a block whose centre is K; the block slides along a straight rail 16.3 mm to the right of F. Set up coordinates with F at the origin. Place the lever so that pin H is level with F, with the arm FH reaching out to the right and the arm FG standing up above F. In this position the block has been driven to sit -6.5 mm relative to the level of F, measured up the rail. The pull-rod has not been cut to length yet - work out where every pin sits, and how long that rod has to be.

"""Bell crank with the pull-rod length to be found

Oracle formalization for mechh_t4_mechh_bell_crank_derived_0061. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(28)

F, G, H, K = scene.add.points(["F", "G", "H", "K"])

scene.constraint.eq(F.x, 0, description="datum: F is the origin, the fixed pin of the bent lever (x)")
scene.constraint.eq(F.y, 0, description="datum: F is the origin, the fixed pin of the bent lever (y)")
scene.constraint.eq(H.y, F.y, description="pin H is level with the fixed pin F")
scene.constraint.gt(H.x - F.x, 1.0, description="the arm FH reaches out in the +x direction")
scene.constraint.eq(F.distance(H), 9.7, description="the arm FH is 9.7 long")
scene.constraint.eq(F.distance(G), 17.7, description="the arm FG is 17.7 long")
scene.relate.right_angle(G, F, H)
scene.constraint.gt(G.y - F.y, 0.05, description="the arm FG stands up above the fixed pin")
scene.constraint.eq(K.x - F.x, 16.3, description="the block runs on a straight rail 16.3 to the right of F")
scene.constraint.eq(K.y - F.y, -6.5, description="in this position the block sits -6.5 relative to the level of F")

the rod length is NOT given - it is whatever is needed to span from G to the stated block position

'H is level with F' means H has the same height as F, so arm FH lies along the datum direction

the right angle at F then forces arm FG to stand straight up

with both G and K fully pinned, the rod length is simply the distance between them


A bent lever turns about a fixed pin F. One arm runs 12.5 mm from F out to a pin H, the other runs 17.1 mm from F out to a pin G, and the two arms are set at a right angle to each other at F. A straight pull-rod connects pin G to a block whose centre is K; the block slides along a straight rail 22.3 mm to the right of F. Set up coordinates with F at the origin. Place the lever so that pin H is level with F, with the arm FH reaching out to the right and the arm FG standing up above F. In this position the block has been driven to sit -5.1 mm relative to the level of F, measured up the rail. The pull-rod has not been cut to length yet - work out where every pin sits, and how long that rod has to be.

"""Bell crank with the pull-rod length to be found

Oracle formalization for mechh_t4_mechh_bell_crank_derived_0062. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(34)

F, G, H, K = scene.add.points(["F", "G", "H", "K"])

scene.constraint.eq(F.x, 0, description="datum: F is the origin, the fixed pin of the bent lever (x)")
scene.constraint.eq(F.y, 0, description="datum: F is the origin, the fixed pin of the bent lever (y)")
scene.constraint.eq(H.y, F.y, description="pin H is level with the fixed pin F")
scene.constraint.gt(H.x - F.x, 1.0, description="the arm FH reaches out in the +x direction")
scene.constraint.eq(F.distance(H), 12.5, description="the arm FH is 12.5 long")
scene.constraint.eq(F.distance(G), 17.1, description="the arm FG is 17.1 long")
scene.relate.right_angle(G, F, H)
scene.constraint.gt(G.y - F.y, 0.05, description="the arm FG stands up above the fixed pin")
scene.constraint.eq(K.x - F.x, 22.3, description="the block runs on a straight rail 22.3 to the right of F")
scene.constraint.eq(K.y - F.y, -5.1, description="in this position the block sits -5.1 relative to the level of F")


A bent lever turns about a fixed pin F. One arm runs 12.1 mm from F out to a pin H, the other runs 15.4 mm from F out to a pin G, and the two arms are set at a right angle to each other at F. A straight pull-rod connects pin G to a block whose centre is K; the block slides along a straight rail 16.7 mm to the right of F. Set up coordinates with F at the origin. Place the lever so that pin H is level with F, with the arm FH reaching out to the right and the arm FG standing up above F. In this position the block has been driven to sit -5.5 mm relative to the level of F, measured up the rail. The pull-rod has not been cut to length yet - work out where every pin sits, and how long that rod has to be.

"""Bell crank with the pull-rod length to be found

Oracle formalization for mechh_t4_mechh_bell_crank_derived_0063. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(27)

F, G, H, K = scene.add.points(["F", "G", "H", "K"])

scene.constraint.eq(F.x, 0, description="datum: F is the origin, the fixed pin of the bent lever (x)")
scene.constraint.eq(F.y, 0, description="datum: F is the origin, the fixed pin of the bent lever (y)")
scene.constraint.eq(H.y, F.y, description="pin H is level with the fixed pin F")
scene.constraint.gt(H.x - F.x, 1.0, description="the arm FH reaches out in the +x direction")
scene.constraint.eq(F.distance(H), 12.1, description="the arm FH is 12.1 long")
scene.constraint.eq(F.distance(G), 15.4, description="the arm FG is 15.4 long")
scene.relate.right_angle(G, F, H)
scene.constraint.gt(G.y - F.y, 0.05, description="the arm FG stands up above the fixed pin")
scene.constraint.eq(K.x - F.x, 16.7, description="the block runs on a straight rail 16.7 to the right of F")
scene.constraint.eq(K.y - F.y, -5.5, description="in this position the block sits -5.5 relative to the level of F")


A bent lever turns about a fixed pin F. One arm runs 13.5 mm from F out to a pin H, the other runs 14.9 mm from F out to a pin G, and the two arms are set at a right angle to each other at F. A straight pull-rod connects pin G to a block whose centre is K; the block slides along a straight rail 22.5 mm to the right of F. Set up coordinates with F at the origin. Place the lever so that pin H is level with F, with the arm FH reaching out to the right and the arm FG standing up above F. In this position the block has been driven to sit -7.3 mm relative to the level of F, measured up the rail. The pull-rod has not been cut to length yet - work out where every pin sits, and how long that rod has to be.

"""Bell crank with the pull-rod length to be found

Oracle formalization for mechh_t4_mechh_bell_crank_derived_0064. Every constraint below corresponds to one
statement in the problem text; the datum constraints fix the coordinate frame
the text describes, and the inequality constraints encode the discrete choices
the text makes explicit (which side, which branch).
"""
from pygeox import GeoScene

def cross(A, B, P):
    """z-component of (B-A) x (P-A). Positive iff P lies to the LEFT of the
    directed line A->B. Used to state 'above', 'on the far side', 'anticlockwise'
    without any appeal to a picture."""
    return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x)

def dot(A, B, C, D):
    """(B-A) . (D-C). Positive iff the two directions point the same way."""
    return (B.x - A.x) * (D.x - C.x) + (B.y - A.y) * (D.y - C.y)

scene = GeoScene(34)

F, G, H, K = scene.add.points(["F", "G", "H", "K"])

scene.constraint.eq(F.x, 0, description="datum: F is the origin, the fixed pin of the bent lever (x)")
scene.constraint.eq(F.y, 0, description="datum: F is the origin, the fixed pin of the bent lever (y)")
scene.constraint.eq(H.y, F.y, description="pin H is level with the fixed pin F")
scene.constraint.gt(H.x - F.x, 1.0, description="the arm FH reaches out in the +x direction")
scene.constraint.eq(F.distance(H), 13.5, description="the arm FH is 13.5 long")
scene.constraint.eq(F.distance(G), 14.9, description="the arm FG is 14.9 long")
scene.relate.right_angle(G, F, H)
scene.constraint.gt(G.y - F.y, 0.05, description="the arm FG stands up above the fixed pin")
scene.constraint.eq(K.x - F.x, 22.5, description="the block runs on a straight rail 22.5 to the right of F")
scene.constraint.eq(K.y - F.y, -7.3, description="in this position the block sits -7.3 relative to the level of F")