A bent lever turns about a fixed pin F. One arm runs 18.9 mm from F out to a pin G, the other arm runs 9.4 mm from F out to a pin H, and the two arms are set at a right angle to each other at F. A straight pull-rod 31.4 mm long connects pin G to a block whose centre is K; the block slides along a straight rail that runs 21.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 sits below the level of pin G.

"""Bell crank with a pull-rod to a rail

Oracle formalization for mech_t2_mech_bell_crank_0042. 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(33)

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(G), 18.9, description="the arm FG is 18.9 long")
scene.constraint.eq(F.distance(H), 9.4, description="the arm FH is 9.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, 21.7, description="the block runs on a straight rail 21.7 to the right of F")
scene.constraint.eq(G.distance(K), 31.4, description="the pull-rod from G to the block is 31.4 long")
scene.constraint.lt(K.y - G.y, -0.05, description="the block sits below the level of pin G")


A bent lever turns about a fixed pin F. One arm runs 16.2 mm from F out to a pin G, the other arm runs 12.8 mm from F out to a pin H, and the two arms are set at a right angle to each other at F. A straight pull-rod 28.9 mm long connects pin G to a block whose centre is K; the block slides along a straight rail that runs 22.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 sits below the level of pin G.

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.

"""Bell crank with a pull-rod to a rail

Oracle formalization for mech_t2_mech_bell_crank_0043. 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)

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(G), 16.2, description="the arm FG is 16.2 long")
scene.constraint.eq(F.distance(H), 12.8, description="the arm FH is 12.8 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.7, description="the block runs on a straight rail 22.7 to the right of F")
scene.constraint.eq(G.distance(K), 28.9, description="the pull-rod from G to the block is 28.9 long")
scene.constraint.lt(K.y - G.y, -0.05, description="the block sits below the level of pin G")

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

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

the block lies on the vertical line at the stated offset from F

the block is where a circle of the rod length centred at G cuts that vertical line - two crossings

the block sits below the level of G, which picks one of the two crossings


A bent lever turns about a fixed pin F. One arm runs 15.7 mm from F out to a pin G, the other arm runs 12.8 mm from F out to a pin H, and the two arms are set at a right angle to each other at F. A straight pull-rod 28.5 mm long connects pin G to a block whose centre is K; the block slides along a straight rail that runs 18.9 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 sits below the level of pin G.

"""Bell crank with a pull-rod to a rail

Oracle formalization for mech_t2_mech_bell_crank_0044. 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)

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(G), 15.7, description="the arm FG is 15.7 long")
scene.constraint.eq(F.distance(H), 12.8, description="the arm FH is 12.8 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, 18.9, description="the block runs on a straight rail 18.9 to the right of F")
scene.constraint.eq(G.distance(K), 28.5, description="the pull-rod from G to the block is 28.5 long")
scene.constraint.lt(K.y - G.y, -0.05, description="the block sits below the level of pin G")


A bent lever turns about a fixed pin F. One arm runs 16.2 mm from F out to a pin G, the other arm runs 11.3 mm from F out to a pin H, and the two arms are set at a right angle to each other at F. A straight pull-rod 21.2 mm long connects pin G to a block whose centre is K; the block slides along a straight rail that runs 16.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 sits below the level of pin G.

"""Bell crank with a pull-rod to a rail

Oracle formalization for mech_t2_mech_bell_crank_0045. 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(26)

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(G), 16.2, description="the arm FG is 16.2 long")
scene.constraint.eq(F.distance(H), 11.3, description="the arm FH is 11.3 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.5, description="the block runs on a straight rail 16.5 to the right of F")
scene.constraint.eq(G.distance(K), 21.2, description="the pull-rod from G to the block is 21.2 long")
scene.constraint.lt(K.y - G.y, -0.05, description="the block sits below the level of pin G")


A bent lever turns about a fixed pin F. One arm runs 16.2 mm from F out to a pin G, the other arm runs 12.5 mm from F out to a pin H, and the two arms are set at a right angle to each other at F. A straight pull-rod 30.8 mm long connects pin G to a block whose centre is K; the block slides along a straight rail that runs 20.4 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 sits below the level of pin G.

"""Bell crank with a pull-rod to a rail

Oracle formalization for mech_t2_mech_bell_crank_0046. 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)

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(G), 16.2, description="the arm FG is 16.2 long")
scene.constraint.eq(F.distance(H), 12.5, description="the arm FH is 12.5 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, 20.4, description="the block runs on a straight rail 20.4 to the right of F")
scene.constraint.eq(G.distance(K), 30.8, description="the pull-rod from G to the block is 30.8 long")
scene.constraint.lt(K.y - G.y, -0.05, description="the block sits below the level of pin G")


A bent lever turns about a fixed pin F. One arm runs 13.8 mm from F out to a pin G, the other arm runs 9.2 mm from F out to a pin H, and the two arms are set at a right angle to each other at F. A straight pull-rod 29.3 mm long connects pin G to a block whose centre is K; the block slides along a straight rail that runs 17.4 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 sits below the level of pin G.

"""Bell crank with a pull-rod to a rail

Oracle formalization for mech_t2_mech_bell_crank_0047. 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(G), 13.8, description="the arm FG is 13.8 long")
scene.constraint.eq(F.distance(H), 9.2, description="the arm FH is 9.2 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, 17.4, description="the block runs on a straight rail 17.4 to the right of F")
scene.constraint.eq(G.distance(K), 29.3, description="the pull-rod from G to the block is 29.3 long")
scene.constraint.lt(K.y - G.y, -0.05, description="the block sits below the level of pin G")


A bent lever turns about a fixed pin F. One arm runs 18 mm from F out to a pin G, the other arm runs 11 mm from F out to a pin H, and the two arms are set at a right angle to each other at F. A straight pull-rod 27.8 mm long connects pin G to a block whose centre is K; the block slides along a straight rail that runs 23.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 sits below the level of pin G.

"""Bell crank with a pull-rod to a rail

Oracle formalization for mech_t2_mech_bell_crank_0048. 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)

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(G), 18, description="the arm FG is 18 long")
scene.constraint.eq(F.distance(H), 11, description="the arm FH is 11 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, 23.5, description="the block runs on a straight rail 23.5 to the right of F")
scene.constraint.eq(G.distance(K), 27.8, description="the pull-rod from G to the block is 27.8 long")
scene.constraint.lt(K.y - G.y, -0.05, description="the block sits below the level of pin G")


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (21.9, 8.3) - call that position N1 - and (9.3, 23.2) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 28.3 mm long connects the end of the first bar to a pin that slides along a straight rail at height 29.6; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_0057. 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)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 21.9, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 8.3, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 9.3, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 23.2, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 29.6, description="the sliding pin runs on a straight rail at height 29.6 (first position)")
scene.constraint.eq(Q2.y, 29.6, description="the sliding pin runs on a straight rail at height 29.6 (second position)")
scene.constraint.eq(N1.distance(Q1), 28.3, description="the connecting bar is 28.3 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 28.3, description="the connecting bar is 28.3 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")

the bar is rigid and M is fixed, so both required positions are the SAME distance from M

therefore M lies on the perpendicular bisector of the segment joining the two positions

combined with 'M is on the base line', that pins M completely

the connecting bar has the same length in both positions, so each sliding pin is that far from its bar end

the sliding pin is to the right of the bar end in each position, picking one crossing of each circle with the rail


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (19.7, 7.9) - call that position N1 - and (7.5, 17.5) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 28.4 mm long connects the end of the first bar to a pin that slides along a straight rail at height 26.3; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_0058. 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(59)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 19.7, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 7.9, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 7.5, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 17.5, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 26.3, description="the sliding pin runs on a straight rail at height 26.3 (first position)")
scene.constraint.eq(Q2.y, 26.3, description="the sliding pin runs on a straight rail at height 26.3 (second position)")
scene.constraint.eq(N1.distance(Q1), 28.4, description="the connecting bar is 28.4 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 28.4, description="the connecting bar is 28.4 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (18.4, 10) - call that position N1 - and (8, 19.3) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 23.8 mm long connects the end of the first bar to a pin that slides along a straight rail at height 25.5; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_0059. 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(52)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 18.4, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 10, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 8, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 19.3, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 25.5, description="the sliding pin runs on a straight rail at height 25.5 (first position)")
scene.constraint.eq(Q2.y, 25.5, description="the sliding pin runs on a straight rail at height 25.5 (second position)")
scene.constraint.eq(N1.distance(Q1), 23.8, description="the connecting bar is 23.8 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 23.8, description="the connecting bar is 23.8 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (21.7, 11) - call that position N1 - and (10.3, 22.7) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 24.3 mm long connects the end of the first bar to a pin that slides along a straight rail at height 33.3; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_0060. 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(48)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 21.7, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 11, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 10.3, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 22.7, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 33.3, description="the sliding pin runs on a straight rail at height 33.3 (first position)")
scene.constraint.eq(Q2.y, 33.3, description="the sliding pin runs on a straight rail at height 33.3 (second position)")
scene.constraint.eq(N1.distance(Q1), 24.3, description="the connecting bar is 24.3 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 24.3, description="the connecting bar is 24.3 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (21.3, 10.9) - call that position N1 - and (7.1, 17.4) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 29.7 mm long connects the end of the first bar to a pin that slides along a straight rail at height 23.5; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_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(68)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 21.3, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 10.9, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 7.1, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 17.4, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 23.5, description="the sliding pin runs on a straight rail at height 23.5 (first position)")
scene.constraint.eq(Q2.y, 23.5, description="the sliding pin runs on a straight rail at height 23.5 (second position)")
scene.constraint.eq(N1.distance(Q1), 29.7, description="the connecting bar is 29.7 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 29.7, description="the connecting bar is 29.7 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (20.2, 8.9) - call that position N1 - and (10.9, 16.2) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 25.4 mm long connects the end of the first bar to a pin that slides along a straight rail at height 27.3; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_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(54)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 20.2, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 8.9, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 10.9, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 16.2, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 27.3, description="the sliding pin runs on a straight rail at height 27.3 (first position)")
scene.constraint.eq(Q2.y, 27.3, description="the sliding pin runs on a straight rail at height 27.3 (second position)")
scene.constraint.eq(N1.distance(Q1), 25.4, description="the connecting bar is 25.4 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 25.4, description="the connecting bar is 25.4 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (19.2, 9.6) - call that position N1 - and (11.6, 19.4) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 21 mm long connects the end of the first bar to a pin that slides along a straight rail at height 27.7; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_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(45)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 19.2, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 9.6, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 11.6, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 19.4, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 27.7, description="the sliding pin runs on a straight rail at height 27.7 (first position)")
scene.constraint.eq(Q2.y, 27.7, description="the sliding pin runs on a straight rail at height 27.7 (second position)")
scene.constraint.eq(N1.distance(Q1), 21, description="the connecting bar is 21 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 21, description="the connecting bar is 21 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")


A bar is pinned to the bench at a fixed pin M and swings in the plane; its free end is N. Working on the bench grid, the end N has to be able to reach both (20.8, 11.2) - call that position N1 - and (10.5, 18.1) - call that N2. The fixed pin M has to be mounted somewhere on the bench base line, which is the line at height 0. A second bar 27.6 mm long connects the end of the first bar to a pin that slides along a straight rail at height 25.3; call that sliding pin Q1 when the end is at N1 and Q2 when it is at N2. In both positions the sliding pin lies to the right of the bar end. Both bars are rigid, so neither changes length as the mechanism moves.

"""Rocker reaching two required positions

Oracle formalization for mech_t2_mech_rocker_two_positions_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(63)

M, N1, N2, Q1, Q2 = scene.add.points(["M", "N1", "N2", "Q1", "Q2"])

scene.constraint.eq(N1.x, 20.8, description="the first required position of the bar end (x)")
scene.constraint.eq(N1.y, 11.2, description="the first required position of the bar end (y)")
scene.constraint.eq(N2.x, 10.5, description="the second required position of the bar end (x)")
scene.constraint.eq(N2.y, 18.1, description="the second required position of the bar end (y)")
scene.constraint.eq(M.y, 0, description="the fixed pin M is mounted on the bench base line, the line y = 0")
scene.constraint.eq(M.distance(N1), M.distance(N2), description="the bar is rigid, so its end is the same distance from M in both positions")
scene.constraint.eq(Q1.y, 25.3, description="the sliding pin runs on a straight rail at height 25.3 (first position)")
scene.constraint.eq(Q2.y, 25.3, description="the sliding pin runs on a straight rail at height 25.3 (second position)")
scene.constraint.eq(N1.distance(Q1), 27.6, description="the connecting bar is 27.6 long, the same in both positions (first)")
scene.constraint.eq(N2.distance(Q2), 27.6, description="the connecting bar is 27.6 long, the same in both positions (second)")
scene.constraint.gt(Q1.x - N1.x, 0.05, description="the sliding pin lies to the right of the bar end in the first position")
scene.constraint.gt(Q2.x - N2.x, 0.05, description="the sliding pin lies to the right of the bar end in the second position")


Three rigid rods are joined end to end by pins to make a chain. The first rod is 15.8 mm long, the second 14.2 mm and the third 11 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (27.2, 15.8), and at that moment the last rod must point 35 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (8.9, 0.7) and a radius of 3.3 mm; no joint of the chain may come within 3 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0017. 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)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 27.2, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 15.8, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 15.8, description="the first rod is 15.8 long")
scene.constraint.eq(J1.distance(J2), 14.2, description="the second rod is 14.2 long")
scene.constraint.eq(J2.distance(J3), 11, description="the third rod is 11 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 145, description="the last rod points 35 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 8.9, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, 0.7, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 3.3, description="the post is 3.3 in radius")
scene.constraint.geq(J1.distance(W) - 3.3, 3, description="joint J1 keeps at least 3 clear of the post")
scene.constraint.geq(J2.distance(W) - 3.3, 3, description="joint J2 keeps at least 3 clear of the post")

consecutive pins are exactly one rod length apart

the stated direction of the last rod fixes J2 at the tip minus the rod length times (cos, sin) of that angle

with J0 and J2 both known, J1 is where two circles cross - two solutions

the clearance is measured from the post SURFACE, so each joint is at least (post radius + clearance) from W

the clearance statements are inequalities, unlike the rod lengths

'elbow up' picks one of the two circle intersections for J1


Three rigid rods are joined end to end by pins to make a chain. The first rod is 17.4 mm long, the second 12.4 mm and the third 11 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (21.2, 11.2), and at that moment the last rod must point 35 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (13.1, -6.7) and a radius of 4.4 mm; no joint of the chain may come within 2.4 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0018. 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(46)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 21.2, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 11.2, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 17.4, description="the first rod is 17.4 long")
scene.constraint.eq(J1.distance(J2), 12.4, description="the second rod is 12.4 long")
scene.constraint.eq(J2.distance(J3), 11, description="the third rod is 11 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 145, description="the last rod points 35 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 13.1, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, -6.7, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 4.4, description="the post is 4.4 in radius")
scene.constraint.geq(J1.distance(W) - 4.4, 2.4, description="joint J1 keeps at least 2.4 clear of the post")
scene.constraint.geq(J2.distance(W) - 4.4, 2.4, description="joint J2 keeps at least 2.4 clear of the post")


Three rigid rods are joined end to end by pins to make a chain. The first rod is 17.6 mm long, the second 13.5 mm and the third 7.3 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (22.3, 17.8), and at that moment the last rod must point 35 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (17.5, -5.2) and a radius of 5.4 mm; no joint of the chain may come within 1.9 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0019. 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)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 22.3, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 17.8, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 17.6, description="the first rod is 17.6 long")
scene.constraint.eq(J1.distance(J2), 13.5, description="the second rod is 13.5 long")
scene.constraint.eq(J2.distance(J3), 7.3, description="the third rod is 7.3 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 145, description="the last rod points 35 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 17.5, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, -5.2, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 5.4, description="the post is 5.4 in radius")
scene.constraint.geq(J1.distance(W) - 5.4, 1.9, description="joint J1 keeps at least 1.9 clear of the post")
scene.constraint.geq(J2.distance(W) - 5.4, 1.9, description="joint J2 keeps at least 1.9 clear of the post")


Three rigid rods are joined end to end by pins to make a chain. The first rod is 19.8 mm long, the second 14 mm and the third 11.2 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (21.4, 12.1), and at that moment the last rod must point 30 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (8.1, -3) and a radius of 4.5 mm; no joint of the chain may come within 3 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0020. 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(46)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 21.4, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 12.1, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 19.8, description="the first rod is 19.8 long")
scene.constraint.eq(J1.distance(J2), 14, description="the second rod is 14 long")
scene.constraint.eq(J2.distance(J3), 11.2, description="the third rod is 11.2 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 150, description="the last rod points 30 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 8.1, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, -3, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 4.5, description="the post is 4.5 in radius")
scene.constraint.geq(J1.distance(W) - 4.5, 3, description="joint J1 keeps at least 3 clear of the post")
scene.constraint.geq(J2.distance(W) - 4.5, 3, description="joint J2 keeps at least 3 clear of the post")


Three rigid rods are joined end to end by pins to make a chain. The first rod is 16.8 mm long, the second 14.3 mm and the third 9.9 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (24.4, 16.2), and at that moment the last rod must point 35 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (12.7, 1.1) and a radius of 4.3 mm; no joint of the chain may come within 2.9 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0021. 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(50)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 24.4, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 16.2, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 16.8, description="the first rod is 16.8 long")
scene.constraint.eq(J1.distance(J2), 14.3, description="the second rod is 14.3 long")
scene.constraint.eq(J2.distance(J3), 9.9, description="the third rod is 9.9 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 145, description="the last rod points 35 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 12.7, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, 1.1, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 4.3, description="the post is 4.3 in radius")
scene.constraint.geq(J1.distance(W) - 4.3, 2.9, description="joint J1 keeps at least 2.9 clear of the post")
scene.constraint.geq(J2.distance(W) - 4.3, 2.9, description="joint J2 keeps at least 2.9 clear of the post")


Three rigid rods are joined end to end by pins to make a chain. The first rod is 18.2 mm long, the second 14.3 mm and the third 10.1 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (21.9, 15.8), and at that moment the last rod must point 25 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (8.1, -5.9) and a radius of 3.7 mm; no joint of the chain may come within 1.9 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0022. 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(46)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 21.9, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 15.8, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 18.2, description="the first rod is 18.2 long")
scene.constraint.eq(J1.distance(J2), 14.3, description="the second rod is 14.3 long")
scene.constraint.eq(J2.distance(J3), 10.1, description="the third rod is 10.1 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 155, description="the last rod points 25 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 8.1, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, -5.9, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 3.7, description="the post is 3.7 in radius")
scene.constraint.geq(J1.distance(W) - 3.7, 1.9, description="joint J1 keeps at least 1.9 clear of the post")
scene.constraint.geq(J2.distance(W) - 3.7, 1.9, description="joint J2 keeps at least 1.9 clear of the post")


Three rigid rods are joined end to end by pins to make a chain. The first rod is 14.9 mm long, the second 12.4 mm and the third 7.7 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (28.6, 13.4), and at that moment the last rod must point 45 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (15.1, -6.3) and a radius of 4.9 mm; no joint of the chain may come within 2.8 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0023. 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(55)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 28.6, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 13.4, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 14.9, description="the first rod is 14.9 long")
scene.constraint.eq(J1.distance(J2), 12.4, description="the second rod is 12.4 long")
scene.constraint.eq(J2.distance(J3), 7.7, description="the third rod is 7.7 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 135, description="the last rod points 45 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 15.1, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, -6.3, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 4.9, description="the post is 4.9 in radius")
scene.constraint.geq(J1.distance(W) - 4.9, 2.8, description="joint J1 keeps at least 2.8 clear of the post")
scene.constraint.geq(J2.distance(W) - 4.9, 2.8, description="joint J2 keeps at least 2.8 clear of the post")


Three rigid rods are joined end to end by pins to make a chain. The first rod is 14.5 mm long, the second 15.6 mm and the third 9.7 mm. Set up coordinates with the base pin at the origin J0; the joint between the first and second rods is J1, the joint between the second and third is J2, and the far tip of the last rod is J3. The tip must sit exactly at (28.7, 13.9), and at that moment the last rod must point 35 degrees above the horizontal, running upwards from J2 to the tip. A construction point E, 10 mm to the right of the tip and level with it, is provided so that angle can be measured. The chain must fold with the middle joint J1 standing above the straight line from J0 to J2. A round post stands on the bench with its centre W at (13.9, -2.4) and a radius of 4.3 mm; no joint of the chain may come within 2.6 mm of the post.

"""Three-rod chain reaching a required pose

Oracle formalization for mech_t2_mech_three_rod_reach_0024. 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(55)

J0, J1, J2, J3, E, W = scene.add.points(["J0", "J1", "J2", "J3", "E", "W"])

scene.constraint.eq(J0.x, 0, description="datum: J0 is the origin, the fixed base pin (x)")
scene.constraint.eq(J0.y, 0, description="datum: J0 is the origin, the fixed base pin (y)")
scene.constraint.eq(J3.x, 28.7, description="the tip of the chain must sit at the required point (x)")
scene.constraint.eq(J3.y, 13.9, description="the tip of the chain must sit at the required point (y)")
scene.constraint.eq(E.y, J3.y, description="construction point E is level with the tip")
scene.constraint.eq(E.x - J3.x, 10, description="construction point E is 10 mm from the tip in the datum direction, so the last rod's angle can be measured")
scene.constraint.eq(J0.distance(J1), 14.5, description="the first rod is 14.5 long")
scene.constraint.eq(J1.distance(J2), 15.6, description="the second rod is 15.6 long")
scene.constraint.eq(J2.distance(J3), 9.7, description="the third rod is 9.7 long")
scene.constraint.eq(scene.add.angle(J2, J3, E).value, 145, description="the last rod points 35 degrees above the datum direction, running up towards the tip")
scene.constraint.lt(cross(J3, E, J2), -0.05, description="the last rod comes up from below-left, so J2 is below the datum direction seen from the tip")
scene.constraint.gt(cross(J0, J2, J1), 0.05, description="the middle joint J1 stands above the straight line from the base pin to J2 (elbow up)")
scene.constraint.eq(W.x, 13.9, description="the post centre is fixed on the bench (x)")
scene.constraint.eq(W.y, -2.4, description="the post centre is fixed on the bench (y)")
post = scene.add.circle(W)
scene.constraint.eq(post.radius, 4.3, description="the post is 4.3 in radius")
scene.constraint.geq(J1.distance(W) - 4.3, 2.6, description="joint J1 keeps at least 2.6 clear of the post")
scene.constraint.geq(J2.distance(W) - 4.3, 2.6, description="joint J2 keeps at least 2.6 clear of the post")


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 10.5 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 22.4 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 8.7 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 172 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0049. 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(46)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -8.7, description="the clamping pad presses on a flat workpiece surface 8.7 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 10.5, description="the first bar JK is 10.5 long")
scene.constraint.eq(K.distance(L), 22.4, description="the second bar KL is 22.4 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 172, description="in the clamped position the angle at pin K, between the two bars, is 172 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")

the workpiece surface is the horizontal line at the stated depth, so L's height is fixed

'very nearly straight' means J, K and L are close to collinear but not exactly so

the distance from J to the pad follows from the cosine rule on the angle at K

K is then where two circles cross - two solutions

the elbow stands above the line JL, which picks one of the two crossings


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 12 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 22.8 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 13.4 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 172 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0050. 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)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -13.4, description="the clamping pad presses on a flat workpiece surface 13.4 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 12, description="the first bar JK is 12 long")
scene.constraint.eq(K.distance(L), 22.8, description="the second bar KL is 22.8 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 172, description="in the clamped position the angle at pin K, between the two bars, is 172 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 13.6 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 18.4 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 13.1 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 172 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0051. 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(43)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -13.1, description="the clamping pad presses on a flat workpiece surface 13.1 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 13.6, description="the first bar JK is 13.6 long")
scene.constraint.eq(K.distance(L), 18.4, description="the second bar KL is 18.4 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 172, description="in the clamped position the angle at pin K, between the two bars, is 172 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 15.9 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 25.2 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 8.9 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 172 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0052. 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(57)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -8.9, description="the clamping pad presses on a flat workpiece surface 8.9 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 15.9, description="the first bar JK is 15.9 long")
scene.constraint.eq(K.distance(L), 25.2, description="the second bar KL is 25.2 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 172, description="in the clamped position the angle at pin K, between the two bars, is 172 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 14.7 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 19.6 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 11.8 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 170 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0053. 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)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -11.8, description="the clamping pad presses on a flat workpiece surface 11.8 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 14.7, description="the first bar JK is 14.7 long")
scene.constraint.eq(K.distance(L), 19.6, description="the second bar KL is 19.6 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 170, description="in the clamped position the angle at pin K, between the two bars, is 170 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 11.1 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 22.6 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 12 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 170 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0054. 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(46)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -12, description="the clamping pad presses on a flat workpiece surface 12 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 11.1, description="the first bar JK is 11.1 long")
scene.constraint.eq(K.distance(L), 22.6, description="the second bar KL is 22.6 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 170, description="in the clamped position the angle at pin K, between the two bars, is 170 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 11.1 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 24.2 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 7.1 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 168 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0055. 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(50)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -7.1, description="the clamping pad presses on a flat workpiece surface 7.1 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 11.1, description="the first bar JK is 11.1 long")
scene.constraint.eq(K.distance(L), 24.2, description="the second bar KL is 24.2 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 168, description="in the clamped position the angle at pin K, between the two bars, is 168 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")


A toggle clamp is made of two bars. The first is pinned to the bench at a fixed pin J and is 15.8 mm long, ending at a pin K. The second runs from K to a clamping pad at L and is 21.8 mm long. Set up coordinates with J at the origin. The pad at L presses on a flat workpiece surface, which is the straight line 7.3 mm below J, and the pad lies to the right of J. In the clamped position the two bars are very nearly straight: the angle at pin K, measured between the two bars, is 170 degrees. The elbow at K stands above the straight line from J to the pad.

"""Toggle clamp near its straight position

Oracle formalization for mech_t2_mech_toggle_clamp_0056. 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)

J, K, L = scene.add.points(["J", "K", "L"])

scene.constraint.eq(J.x, 0, description="datum: J is the origin, the fixed pin of the clamp (x)")
scene.constraint.eq(J.y, 0, description="datum: J is the origin, the fixed pin of the clamp (y)")
scene.constraint.eq(L.y, -7.3, description="the clamping pad presses on a flat workpiece surface 7.3 below J")
scene.constraint.gt(L.x, 1.0, description="datum: the pad lies in the +x direction from J")
scene.constraint.eq(J.distance(K), 15.8, description="the first bar JK is 15.8 long")
scene.constraint.eq(K.distance(L), 21.8, description="the second bar KL is 21.8 long")
scene.constraint.eq(scene.add.angle(J, K, L).value, 170, description="in the clamped position the angle at pin K, between the two bars, is 170 degrees")
scene.constraint.gt(cross(J, L, K), 0.05, description="the elbow at K stands above the straight line from J to the pad")


A straight beam 36 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 23.1 mm long down to a block whose centre is K; the block slides on a straight vertical rail 23.6 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.2 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_0073. 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(43)

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), 36, description="the beam is 36 long overall")
scene.constraint.eq(E2.y - Z.y, 7.2, description="the far end E2 sits 7.2 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, -23.6, description="the block runs on a straight rail 23.6 to the left of the pivot")
scene.constraint.eq(E1.distance(K), 23.1, description="the rod from the beam end E1 down to the block is 23.1 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.7 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 21.4 mm long down to a block whose centre is K; the block slides on a straight vertical rail 19 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 10.5 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_0074. 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)

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.7, description="the beam is 30.7 long overall")
scene.constraint.eq(E2.y - Z.y, 10.5, description="the far end E2 sits 10.5 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, -19, description="the block runs on a straight rail 19 to the left of the pivot")
scene.constraint.eq(E1.distance(K), 21.4, description="the rod from the beam end E1 down to the block is 21.4 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 31.2 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 23.2 mm long down to a block whose centre is K; the block slides on a straight vertical rail 23 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 6.4 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_0075. 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)

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), 31.2, description="the beam is 31.2 long overall")
scene.constraint.eq(E2.y - Z.y, 6.4, description="the far end E2 sits 6.4 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, -23, description="the block runs on a straight rail 23 to the left of the pivot")
scene.constraint.eq(E1.distance(K), 23.2, description="the rod from the beam end E1 down to the block is 23.2 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 31.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 18.7 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 10.4 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_0076. 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), 31.9, description="the beam is 31.9 long overall")
scene.constraint.eq(E2.y - Z.y, 10.4, description="the far end E2 sits 10.4 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), 18.7, description="the rod from the beam end E1 down to the block is 18.7 long")
scene.constraint.lt(K.y - E1.y, -0.05, description="the block hangs below the beam end it is connected to")