A straight bar has a small block pinned at each end: one block slides along a horizontal rail, the other along a vertical rail, and the two rails cross at Z, the origin of the coordinates. A scriber is clamped to the bar somewhere along its length and stays put there as the bar moves. Neither the bar's length nor where the scriber is clamped has been recorded - both have to be recovered. The mechanism is caught in two poses. In pose 1 the blocks are Bh1 on the horizontal rail and Bv1 on the vertical rail, and the scriber is at (2.8887, 16.8653). In pose 2 the blocks are Bh2 and Bv2, and the scriber has moved to (5.33, 10.4624). In both poses the vertical-rail block is on the upper half of its rail, and between pose 1 and pose 2 the horizontal-rail block has moved further out along its own rail.

"""Elliptic trammel with unknown bar length and scriber position

Oracle formalization for mechh_t4_mechh_trammel_two_poses_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(34)

Z, Bh1, Bv1, T1, Bh2, Bv2, T2 = scene.add.points(["Z", "Bh1", "Bv1", "T1", "Bh2", "Bv2", "T2"])

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, where the two rails cross (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, where the two rails cross (y)")
scene.constraint.eq(Bh1.y, Z.y, description="in pose 1 the first block sits on the horizontal rail")
scene.constraint.eq(Bh2.y, Z.y, description="in pose 2 the first block sits on the horizontal rail")
scene.constraint.eq(Bv1.x, Z.x, description="in pose 1 the second block sits on the vertical rail")
scene.constraint.eq(Bv2.x, Z.x, description="in pose 2 the second block sits on the vertical rail")
scene.constraint.eq(T1.x, 2.8887, description="the scriber passes through this point in pose 1 (x)")
scene.constraint.eq(T1.y, 16.8653, description="the scriber passes through this point in pose 1 (y)")
scene.constraint.eq(T2.x, 5.33, description="the scriber passes through this point in pose 2 (x)")
scene.constraint.eq(T2.y, 10.4624, description="the scriber passes through this point in pose 2 (y)")
scene.relate.point_lies_on(T1, scene.add.line_segment(Bh1, Bv1))
scene.relate.point_lies_on(T2, scene.add.line_segment(Bh2, Bv2))
scene.constraint.eq(Bh1.distance(Bv1), Bh2.distance(Bv2), description="the bar is rigid, so it is the same length in both poses")
scene.constraint.eq(Bh1.distance(T1), Bh2.distance(T2), description="the scriber is clamped to the bar, so it sits the same distance along it in both poses")
scene.constraint.gt(Bv1.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bv2.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bh2.x - Bh1.x, 0.05, description="the first block has moved outward along its rail from pose 1 to pose 2")


A straight bar has a small block pinned at each end: one block slides along a horizontal rail, the other along a vertical rail, and the two rails cross at Z, the origin of the coordinates. A scriber is clamped to the bar somewhere along its length and stays put there as the bar moves. Neither the bar's length nor where the scriber is clamped has been recorded - both have to be recovered. The mechanism is caught in two poses. In pose 1 the blocks are Bh1 on the horizontal rail and Bv1 on the vertical rail, and the scriber is at (2.9819, 21.6225). In pose 2 the blocks are Bh2 and Bv2, and the scriber has moved to (5.9929, 14.9777). In both poses the vertical-rail block is on the upper half of its rail, and between pose 1 and pose 2 the horizontal-rail block has moved further out along its own rail.

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.

"""Elliptic trammel with unknown bar length and scriber position

Oracle formalization for mechh_t4_mechh_trammel_two_poses_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(42)

Z, Bh1, Bv1, T1, Bh2, Bv2, T2 = scene.add.points(["Z", "Bh1", "Bv1", "T1", "Bh2", "Bv2", "T2"])

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, where the two rails cross (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, where the two rails cross (y)")
scene.constraint.eq(Bh1.y, Z.y, description="in pose 1 the first block sits on the horizontal rail")
scene.constraint.eq(Bh2.y, Z.y, description="in pose 2 the first block sits on the horizontal rail")
scene.constraint.eq(Bv1.x, Z.x, description="in pose 1 the second block sits on the vertical rail")
scene.constraint.eq(Bv2.x, Z.x, description="in pose 2 the second block sits on the vertical rail")
scene.constraint.eq(T1.x, 2.9819, description="the scriber passes through this point in pose 1 (x)")
scene.constraint.eq(T1.y, 21.6225, description="the scriber passes through this point in pose 1 (y)")
scene.constraint.eq(T2.x, 5.9929, description="the scriber passes through this point in pose 2 (x)")
scene.constraint.eq(T2.y, 14.9777, description="the scriber passes through this point in pose 2 (y)")
scene.relate.point_lies_on(T1, scene.add.line_segment(Bh1, Bv1))
scene.relate.point_lies_on(T2, scene.add.line_segment(Bh2, Bv2))
scene.constraint.eq(Bh1.distance(Bv1), Bh2.distance(Bv2), description="the bar is rigid, so it is the same length in both poses")
scene.constraint.eq(Bh1.distance(T1), Bh2.distance(T2), description="the scriber is clamped to the bar, so it sits the same distance along it in both poses")
scene.constraint.gt(Bv1.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bv2.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bh2.x - Bh1.x, 0.05, description="the first block has moved outward along its rail from pose 1 to pose 2")

two quantities are unknown at once - the bar length and the scriber's distance along it - so they cannot be solved one at a time

each block lies on its own rail, so one has height 0 and the other has abscissa 0

the bar is rigid, so its length is the same in both poses; the scriber is clamped, so its distance along the bar is too

the scriber lies ON the bar between the blocks in each pose, which ties the two poses together

the vertical block is on the upper half of its rail in both poses, and the horizontal block moves outward between poses


A straight bar has a small block pinned at each end: one block slides along a horizontal rail, the other along a vertical rail, and the two rails cross at Z, the origin of the coordinates. A scriber is clamped to the bar somewhere along its length and stays put there as the bar moves. Neither the bar's length nor where the scriber is clamped has been recorded - both have to be recovered. The mechanism is caught in two poses. In pose 1 the blocks are Bh1 on the horizontal rail and Bv1 on the vertical rail, and the scriber is at (2.8278, 15.525). In pose 2 the blocks are Bh2 and Bv2, and the scriber has moved to (5.988, 9.8708). In both poses the vertical-rail block is on the upper half of its rail, and between pose 1 and pose 2 the horizontal-rail block has moved further out along its own rail.

"""Elliptic trammel with unknown bar length and scriber position

Oracle formalization for mechh_t4_mechh_trammel_two_poses_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(34)

Z, Bh1, Bv1, T1, Bh2, Bv2, T2 = scene.add.points(["Z", "Bh1", "Bv1", "T1", "Bh2", "Bv2", "T2"])

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, where the two rails cross (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, where the two rails cross (y)")
scene.constraint.eq(Bh1.y, Z.y, description="in pose 1 the first block sits on the horizontal rail")
scene.constraint.eq(Bh2.y, Z.y, description="in pose 2 the first block sits on the horizontal rail")
scene.constraint.eq(Bv1.x, Z.x, description="in pose 1 the second block sits on the vertical rail")
scene.constraint.eq(Bv2.x, Z.x, description="in pose 2 the second block sits on the vertical rail")
scene.constraint.eq(T1.x, 2.8278, description="the scriber passes through this point in pose 1 (x)")
scene.constraint.eq(T1.y, 15.525, description="the scriber passes through this point in pose 1 (y)")
scene.constraint.eq(T2.x, 5.988, description="the scriber passes through this point in pose 2 (x)")
scene.constraint.eq(T2.y, 9.8708, description="the scriber passes through this point in pose 2 (y)")
scene.relate.point_lies_on(T1, scene.add.line_segment(Bh1, Bv1))
scene.relate.point_lies_on(T2, scene.add.line_segment(Bh2, Bv2))
scene.constraint.eq(Bh1.distance(Bv1), Bh2.distance(Bv2), description="the bar is rigid, so it is the same length in both poses")
scene.constraint.eq(Bh1.distance(T1), Bh2.distance(T2), description="the scriber is clamped to the bar, so it sits the same distance along it in both poses")
scene.constraint.gt(Bv1.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bv2.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bh2.x - Bh1.x, 0.05, description="the first block has moved outward along its rail from pose 1 to pose 2")


A straight bar has a small block pinned at each end: one block slides along a horizontal rail, the other along a vertical rail, and the two rails cross at Z, the origin of the coordinates. A scriber is clamped to the bar somewhere along its length and stays put there as the bar moves. Neither the bar's length nor where the scriber is clamped has been recorded - both have to be recovered. The mechanism is caught in two poses. In pose 1 the blocks are Bh1 on the horizontal rail and Bv1 on the vertical rail, and the scriber is at (5.2045, 11.5775). In pose 2 the blocks are Bh2 and Bv2, and the scriber has moved to (10.0739, 6.7175). In both poses the vertical-rail block is on the upper half of its rail, and between pose 1 and pose 2 the horizontal-rail block has moved further out along its own rail.

"""Elliptic trammel with unknown bar length and scriber position

Oracle formalization for mechh_t4_mechh_trammel_two_poses_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(34)

Z, Bh1, Bv1, T1, Bh2, Bv2, T2 = scene.add.points(["Z", "Bh1", "Bv1", "T1", "Bh2", "Bv2", "T2"])

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, where the two rails cross (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, where the two rails cross (y)")
scene.constraint.eq(Bh1.y, Z.y, description="in pose 1 the first block sits on the horizontal rail")
scene.constraint.eq(Bh2.y, Z.y, description="in pose 2 the first block sits on the horizontal rail")
scene.constraint.eq(Bv1.x, Z.x, description="in pose 1 the second block sits on the vertical rail")
scene.constraint.eq(Bv2.x, Z.x, description="in pose 2 the second block sits on the vertical rail")
scene.constraint.eq(T1.x, 5.2045, description="the scriber passes through this point in pose 1 (x)")
scene.constraint.eq(T1.y, 11.5775, description="the scriber passes through this point in pose 1 (y)")
scene.constraint.eq(T2.x, 10.0739, description="the scriber passes through this point in pose 2 (x)")
scene.constraint.eq(T2.y, 6.7175, description="the scriber passes through this point in pose 2 (y)")
scene.relate.point_lies_on(T1, scene.add.line_segment(Bh1, Bv1))
scene.relate.point_lies_on(T2, scene.add.line_segment(Bh2, Bv2))
scene.constraint.eq(Bh1.distance(Bv1), Bh2.distance(Bv2), description="the bar is rigid, so it is the same length in both poses")
scene.constraint.eq(Bh1.distance(T1), Bh2.distance(T2), description="the scriber is clamped to the bar, so it sits the same distance along it in both poses")
scene.constraint.gt(Bv1.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bv2.y - Z.y, 0.05, description="both poses have the second block on the upper half of the vertical rail")
scene.constraint.gt(Bh2.x - Bh1.x, 0.05, description="the first block has moved outward along its rail from pose 1 to pose 2")


Two bars are pinned to the bench at fixed pins U and V, which sit at the same height and are 25.3 mm apart. Set up coordinates with U at the origin and V to its right. The bar at U is 10 mm long and ends at a pin W; the bar at V is 13.3 mm long and ends at a pin X. A third bar joins W to X, but it has not been cut to length yet. In the position of interest both moving pins have been raised to exactly 6 mm above the line joining the two fixed pins, and the two bars are splayed apart - W has swung out to the left of U and X has swung out to the right of V. Work out where W and X sit, and how long the joining bar has to be.

"""Two cranks at a stated level, joining link to be found

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

U, V, W, X = scene.add.points(["U", "V", "W", "X"])

scene.constraint.eq(U.x, 0, description="datum: U is the origin, the first fixed pin (x)")
scene.constraint.eq(U.y, 0, description="datum: U is the origin, the first fixed pin (y)")
scene.constraint.eq(V.y, U.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.gt(V.x - U.x, 1.0, description="datum: V is to the right of U")
scene.constraint.eq(U.distance(V), 25.3, description="the two fixed pins are 25.3 apart")
scene.constraint.eq(U.distance(W), 10, description="the bar at U is 10 long, ending at pin W")
scene.constraint.eq(V.distance(X), 13.3, description="the bar at V is 13.3 long, ending at pin X")
scene.constraint.eq(W.y - U.y, 6, description="both moving pins are raised 6 above the line of the fixed pins")
scene.constraint.eq(X.y - U.y, 6, description="both moving pins are raised 6 above the line of the fixed pins")
scene.constraint.lt(W.x - U.x, -0.05, description="the two bars are splayed apart: W swings out to the left of U")
scene.constraint.gt(X.x - V.x, 0.05, description="the two bars are splayed apart: X swings out to the right of V")

the joining bar's length is NOT given - it follows once both moving pins are placed

each moving pin is at its own bar length from its own fixed pin AND at the stated height

so each is found from a right-angled triangle, and each has a left/right choice to resolve

the joining length is then just the distance between the two pins once both are placed

the bars are splayed apart - W to the left of U, X to the right of V


Two bars are pinned to the bench at fixed pins U and V, which sit at the same height and are 33.7 mm apart. Set up coordinates with U at the origin and V to its right. The bar at U is 11.5 mm long and ends at a pin W; the bar at V is 13.9 mm long and ends at a pin X. A third bar joins W to X, but it has not been cut to length yet. In the position of interest both moving pins have been raised to exactly 9.5 mm above the line joining the two fixed pins, and the two bars are splayed apart - W has swung out to the left of U and X has swung out to the right of V. Work out where W and X sit, and how long the joining bar has to be.

"""Two cranks at a stated level, joining link to be found

Oracle formalization for mechh_t4_mechh_two_cranks_derived_link_0092. 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(62)

U, V, W, X = scene.add.points(["U", "V", "W", "X"])

scene.constraint.eq(U.x, 0, description="datum: U is the origin, the first fixed pin (x)")
scene.constraint.eq(U.y, 0, description="datum: U is the origin, the first fixed pin (y)")
scene.constraint.eq(V.y, U.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.gt(V.x - U.x, 1.0, description="datum: V is to the right of U")
scene.constraint.eq(U.distance(V), 33.7, description="the two fixed pins are 33.7 apart")
scene.constraint.eq(U.distance(W), 11.5, description="the bar at U is 11.5 long, ending at pin W")
scene.constraint.eq(V.distance(X), 13.9, description="the bar at V is 13.9 long, ending at pin X")
scene.constraint.eq(W.y - U.y, 9.5, description="both moving pins are raised 9.5 above the line of the fixed pins")
scene.constraint.eq(X.y - U.y, 9.5, description="both moving pins are raised 9.5 above the line of the fixed pins")
scene.constraint.lt(W.x - U.x, -0.05, description="the two bars are splayed apart: W swings out to the left of U")
scene.constraint.gt(X.x - V.x, 0.05, description="the two bars are splayed apart: X swings out to the right of V")


Two bars are pinned to the bench at fixed pins U and V, which sit at the same height and are 24.8 mm apart. Set up coordinates with U at the origin and V to its right. The bar at U is 10.2 mm long and ends at a pin W; the bar at V is 16.6 mm long and ends at a pin X. A third bar joins W to X, but it has not been cut to length yet. In the position of interest both moving pins have been raised to exactly 5.7 mm above the line joining the two fixed pins, and the two bars are splayed apart - W has swung out to the left of U and X has swung out to the right of V. Work out where W and X sit, and how long the joining bar has to be.

"""Two cranks at a stated level, joining link to be found

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

U, V, W, X = scene.add.points(["U", "V", "W", "X"])

scene.constraint.eq(U.x, 0, description="datum: U is the origin, the first fixed pin (x)")
scene.constraint.eq(U.y, 0, description="datum: U is the origin, the first fixed pin (y)")
scene.constraint.eq(V.y, U.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.gt(V.x - U.x, 1.0, description="datum: V is to the right of U")
scene.constraint.eq(U.distance(V), 24.8, description="the two fixed pins are 24.8 apart")
scene.constraint.eq(U.distance(W), 10.2, description="the bar at U is 10.2 long, ending at pin W")
scene.constraint.eq(V.distance(X), 16.6, description="the bar at V is 16.6 long, ending at pin X")
scene.constraint.eq(W.y - U.y, 5.7, description="both moving pins are raised 5.7 above the line of the fixed pins")
scene.constraint.eq(X.y - U.y, 5.7, description="both moving pins are raised 5.7 above the line of the fixed pins")
scene.constraint.lt(W.x - U.x, -0.05, description="the two bars are splayed apart: W swings out to the left of U")
scene.constraint.gt(X.x - V.x, 0.05, description="the two bars are splayed apart: X swings out to the right of V")


Two bars are pinned to the bench at fixed pins U and V, which sit at the same height and are 24.2 mm apart. Set up coordinates with U at the origin and V to its right. The bar at U is 11.3 mm long and ends at a pin W; the bar at V is 11.4 mm long and ends at a pin X. A third bar joins W to X, but it has not been cut to length yet. In the position of interest both moving pins have been raised to exactly 7.2 mm above the line joining the two fixed pins, and the two bars are splayed apart - W has swung out to the left of U and X has swung out to the right of V. Work out where W and X sit, and how long the joining bar has to be.

"""Two cranks at a stated level, joining link to be found

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

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

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

scene = GeoScene(48)

U, V, W, X = scene.add.points(["U", "V", "W", "X"])

scene.constraint.eq(U.x, 0, description="datum: U is the origin, the first fixed pin (x)")
scene.constraint.eq(U.y, 0, description="datum: U is the origin, the first fixed pin (y)")
scene.constraint.eq(V.y, U.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.gt(V.x - U.x, 1.0, description="datum: V is to the right of U")
scene.constraint.eq(U.distance(V), 24.2, description="the two fixed pins are 24.2 apart")
scene.constraint.eq(U.distance(W), 11.3, description="the bar at U is 11.3 long, ending at pin W")
scene.constraint.eq(V.distance(X), 11.4, description="the bar at V is 11.4 long, ending at pin X")
scene.constraint.eq(W.y - U.y, 7.2, description="both moving pins are raised 7.2 above the line of the fixed pins")
scene.constraint.eq(X.y - U.y, 7.2, description="both moving pins are raised 7.2 above the line of the fixed pins")
scene.constraint.lt(W.x - U.x, -0.05, description="the two bars are splayed apart: W swings out to the left of U")
scene.constraint.gt(X.x - V.x, 0.05, description="the two bars are splayed apart: X swings out to the right of V")


Two bars are pinned to the bench at fixed pins U and V, which sit at the same height and are 27 mm apart. Set up coordinates with U at the origin and V to its right. The bar at U is 12.6 mm long and ends at a pin W; the bar at V is 16 mm long and ends at a pin X. A third bar joins W to X, but it has not been cut to length yet. In the position of interest both moving pins have been raised to exactly 8.1 mm above the line joining the two fixed pins, and the two bars are splayed apart - W has swung out to the left of U and X has swung out to the right of V. Work out where W and X sit, and how long the joining bar has to be.

"""Two cranks at a stated level, joining link to be found

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

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

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

scene = GeoScene(58)

U, V, W, X = scene.add.points(["U", "V", "W", "X"])

scene.constraint.eq(U.x, 0, description="datum: U is the origin, the first fixed pin (x)")
scene.constraint.eq(U.y, 0, description="datum: U is the origin, the first fixed pin (y)")
scene.constraint.eq(V.y, U.y, description="the two fixed pins sit at the same height on the bench")
scene.constraint.gt(V.x - U.x, 1.0, description="datum: V is to the right of U")
scene.constraint.eq(U.distance(V), 27, description="the two fixed pins are 27 apart")
scene.constraint.eq(U.distance(W), 12.6, description="the bar at U is 12.6 long, ending at pin W")
scene.constraint.eq(V.distance(X), 16, description="the bar at V is 16 long, ending at pin X")
scene.constraint.eq(W.y - U.y, 8.1, description="both moving pins are raised 8.1 above the line of the fixed pins")
scene.constraint.eq(X.y - U.y, 8.1, description="both moving pins are raised 8.1 above the line of the fixed pins")
scene.constraint.lt(W.x - U.x, -0.05, description="the two bars are splayed apart: W swings out to the left of U")
scene.constraint.gt(X.x - V.x, 0.05, description="the two bars are splayed apart: X swings out to the right of V")


A straight beam 36.3 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 on the left and E2 on the right. Each end drives its own block down a rail of its own: E1 is connected by a rod 14.8 mm long to a block K1 sliding on a vertical rail 19 mm to the left of the pivot, and E2 is connected by a rod 17.9 mm long to a block K2 sliding on a vertical rail 23 mm to the right of the pivot. Each block hangs below the beam end it is connected to. Arrange the beam so that the right-hand end E2 sits 10.6 mm above the height of the pivot.

"""Walking beam driving two blocks on separate rails

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

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

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

scene = GeoScene(37)

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

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.3, description="the beam is 36.3 long overall")
scene.constraint.eq(E2.y - Z.y, 10.6, description="the right-hand end E2 sits 10.6 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="E2 is the end on the right of the pivot")
scene.constraint.eq(K1.x - Z.x, -19, description="the left-hand block runs on a rail 19 to the left of the pivot")
scene.constraint.eq(K2.x - Z.x, 23, description="the right-hand block runs on a rail 23 to the right of the pivot")
scene.constraint.eq(E1.distance(K1), 14.8, description="the left-hand rod is 14.8 long")
scene.constraint.eq(E2.distance(K2), 17.9, description="the right-hand rod is 17.9 long")
scene.constraint.lt(K1.y - E1.y, -0.05, description="each block hangs below the beam end it is connected to")
scene.constraint.lt(K2.y - E2.y, -0.05, description="each block hangs below the beam end it is connected to")

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

the two ends are diametrically opposite about the pivot, so if E2 is dy above it then E1 is dy BELOW it, with the opposite x-offset too

each block is where a circle of its own rod length, centred on its own beam end, cuts its own rail line

the two sides are worked out separately but both depend on first getting the beam's tilt right

E2 is on the right of the pivot, and each block hangs below its beam end


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 on the left and E2 on the right. Each end drives its own block down a rail of its own: E1 is connected by a rod 13.1 mm long to a block K1 sliding on a vertical rail 17.7 mm to the left of the pivot, and E2 is connected by a rod 16.1 mm long to a block K2 sliding on a vertical rail 19.3 mm to the right of the pivot. Each block hangs below the beam end it is connected to. Arrange the beam so that the right-hand end E2 sits 11.8 mm above the height of the pivot.

"""Walking beam driving two blocks on separate rails

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

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

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

scene = GeoScene(35)

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

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, 11.8, description="the right-hand end E2 sits 11.8 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="E2 is the end on the right of the pivot")
scene.constraint.eq(K1.x - Z.x, -17.7, description="the left-hand block runs on a rail 17.7 to the left of the pivot")
scene.constraint.eq(K2.x - Z.x, 19.3, description="the right-hand block runs on a rail 19.3 to the right of the pivot")
scene.constraint.eq(E1.distance(K1), 13.1, description="the left-hand rod is 13.1 long")
scene.constraint.eq(E2.distance(K2), 16.1, description="the right-hand rod is 16.1 long")
scene.constraint.lt(K1.y - E1.y, -0.05, description="each block hangs below the beam end it is connected to")
scene.constraint.lt(K2.y - E2.y, -0.05, description="each block hangs below the beam end it is connected to")


A straight beam 36.5 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 on the left and E2 on the right. Each end drives its own block down a rail of its own: E1 is connected by a rod 16.3 mm long to a block K1 sliding on a vertical rail 24.9 mm to the left of the pivot, and E2 is connected by a rod 17.7 mm long to a block K2 sliding on a vertical rail 22.2 mm to the right of the pivot. Each block hangs below the beam end it is connected to. Arrange the beam so that the right-hand end E2 sits 9.7 mm above the height of the pivot.

"""Walking beam driving two blocks on separate rails

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

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

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

scene = GeoScene(37)

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

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.5, description="the beam is 36.5 long overall")
scene.constraint.eq(E2.y - Z.y, 9.7, description="the right-hand end E2 sits 9.7 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="E2 is the end on the right of the pivot")
scene.constraint.eq(K1.x - Z.x, -24.9, description="the left-hand block runs on a rail 24.9 to the left of the pivot")
scene.constraint.eq(K2.x - Z.x, 22.2, description="the right-hand block runs on a rail 22.2 to the right of the pivot")
scene.constraint.eq(E1.distance(K1), 16.3, description="the left-hand rod is 16.3 long")
scene.constraint.eq(E2.distance(K2), 17.7, description="the right-hand rod is 17.7 long")
scene.constraint.lt(K1.y - E1.y, -0.05, description="each block hangs below the beam end it is connected to")
scene.constraint.lt(K2.y - E2.y, -0.05, description="each block hangs below the beam end it is connected to")


A straight beam 39.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 on the left and E2 on the right. Each end drives its own block down a rail of its own: E1 is connected by a rod 22.9 mm long to a block K1 sliding on a vertical rail 24.2 mm to the left of the pivot, and E2 is connected by a rod 23.2 mm long to a block K2 sliding on a vertical rail 19.2 mm to the right of the pivot. Each block hangs below the beam end it is connected to. Arrange the beam so that the right-hand end E2 sits 14.8 mm above the height of the pivot.

"""Walking beam driving two blocks on separate rails

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

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

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

scene = GeoScene(50)

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

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), 39.9, description="the beam is 39.9 long overall")
scene.constraint.eq(E2.y - Z.y, 14.8, description="the right-hand end E2 sits 14.8 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="E2 is the end on the right of the pivot")
scene.constraint.eq(K1.x - Z.x, -24.2, description="the left-hand block runs on a rail 24.2 to the left of the pivot")
scene.constraint.eq(K2.x - Z.x, 19.2, description="the right-hand block runs on a rail 19.2 to the right of the pivot")
scene.constraint.eq(E1.distance(K1), 22.9, description="the left-hand rod is 22.9 long")
scene.constraint.eq(E2.distance(K2), 23.2, description="the right-hand rod is 23.2 long")
scene.constraint.lt(K1.y - E1.y, -0.05, description="each block hangs below the beam end it is connected to")
scene.constraint.lt(K2.y - E2.y, -0.05, description="each block hangs below the beam end it is connected to")


A straight beam 37.5 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 on the left and E2 on the right. Each end drives its own block down a rail of its own: E1 is connected by a rod 13.7 mm long to a block K1 sliding on a vertical rail 16.4 mm to the left of the pivot, and E2 is connected by a rod 15.8 mm long to a block K2 sliding on a vertical rail 17.2 mm to the right of the pivot. Each block hangs below the beam end it is connected to. Arrange the beam so that the right-hand end E2 sits 14.2 mm above the height of the pivot.

"""Walking beam driving two blocks on separate rails

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

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

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

scene = GeoScene(40)

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

scene.constraint.eq(Z.x, 0, description="datum: Z is the origin, the fixed pivot of the beam (x)")
scene.constraint.eq(Z.y, 0, description="datum: Z is the origin, the fixed pivot of the beam (y)")
scene.relate.is_midpoint(Z, scene.add.line_segment(E1, E2))
scene.constraint.eq(E1.distance(E2), 37.5, description="the beam is 37.5 long overall")
scene.constraint.eq(E2.y - Z.y, 14.2, description="the right-hand end E2 sits 14.2 above the height of the pivot")
scene.constraint.gt(E2.x - Z.x, 0.05, description="E2 is the end on the right of the pivot")
scene.constraint.eq(K1.x - Z.x, -16.4, description="the left-hand block runs on a rail 16.4 to the left of the pivot")
scene.constraint.eq(K2.x - Z.x, 17.2, description="the right-hand block runs on a rail 17.2 to the right of the pivot")
scene.constraint.eq(E1.distance(K1), 13.7, description="the left-hand rod is 13.7 long")
scene.constraint.eq(E2.distance(K2), 15.8, description="the right-hand rod is 15.8 long")
scene.constraint.lt(K1.y - E1.y, -0.05, description="each block hangs below the beam end it is connected to")
scene.constraint.lt(K2.y - E2.y, -0.05, description="each block hangs below the beam end it is connected to")