A circular flange is drilled with 5 bolt holes spaced evenly around a bolt circle that is 23.9 mm across. Set up coordinates with the flange centre at the origin O and the first hole centre H1 on the positive x-axis; number the hole centres H1, H2, H3, H4, H5 going anticlockwise. Each bolt hole is 3.1 mm across. A circular boss of radius 3.4 mm sits at the centre of the flange, and the design requires at least 1.7 mm of material to remain between the boss and every bolt hole.

"""Bolt circle on a flange

Oracle formalization for cad_t2_cad_bolt_circle_0027. 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(21)

O, H1, H2, H3, H4, H5 = scene.add.points(["O", "H1", "H2", "H3", "H4", "H5"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the flange centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the flange centre (y)")
scene.constraint.eq(H1.y, 0, description="datum: the first hole centre H1 lies on the positive x-axis")
scene.constraint.gt(H1.x, 1.0, description="datum: H1 is on the POSITIVE x side of the centre")
bolt_circle = scene.add.circle(O)
scene.constraint.eq(2 * bolt_circle.radius, 23.9, description="the bolt circle is 23.9 across")
scene.relate.point_lies_on(H1, bolt_circle)
scene.relate.point_lies_on(H2, bolt_circle)
scene.relate.point_lies_on(H3, bolt_circle)
scene.relate.point_lies_on(H4, bolt_circle)
scene.relate.point_lies_on(H5, bolt_circle)
scene.constraint.eq(scene.add.angle(H1, O, H2).value, 72, description="holes H1 and H2 are adjacent on an evenly spaced set of 5")
scene.constraint.gt(cross(O, H1, H2), 0.05, description="the holes are numbered anticlockwise, so H2 follows H1")
scene.constraint.eq(scene.add.angle(H2, O, H3).value, 72, description="holes H2 and H3 are adjacent on an evenly spaced set of 5")
scene.constraint.gt(cross(O, H2, H3), 0.05, description="the holes are numbered anticlockwise, so H3 follows H2")
scene.constraint.eq(scene.add.angle(H3, O, H4).value, 72, description="holes H3 and H4 are adjacent on an evenly spaced set of 5")
scene.constraint.gt(cross(O, H3, H4), 0.05, description="the holes are numbered anticlockwise, so H4 follows H3")
scene.constraint.eq(scene.add.angle(H4, O, H5).value, 72, description="holes H4 and H5 are adjacent on an evenly spaced set of 5")
scene.constraint.gt(cross(O, H4, H5), 0.05, description="the holes are numbered anticlockwise, so H5 follows H4")
scene.constraint.geq(O.distance(H1) - 1.55, 5.1, description="at least 1.7 of material between the central boss and hole H1")
scene.constraint.geq(O.distance(H2) - 1.55, 5.1, description="at least 1.7 of material between the central boss and hole H2")
scene.constraint.geq(O.distance(H3) - 1.55, 5.1, description="at least 1.7 of material between the central boss and hole H3")
scene.constraint.geq(O.distance(H4) - 1.55, 5.1, description="at least 1.7 of material between the central boss and hole H4")
scene.constraint.geq(O.distance(H5) - 1.55, 5.1, description="at least 1.7 of material between the central boss and hole H5")


A rectangular plate measures 35.3 mm by 31.5 mm. Set up coordinates with the bottom-left corner at the origin P, the 35.3 mm edge running from P along the positive x-direction to Q, and the 31.5 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 8.6 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 4.4 mm across is drilled with its centre N at 16.1 mm from edge PS and 12.4 mm from edge PQ. At least 2.8 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

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.

"""Chamfered corner with a clearance hole

Oracle formalization for cad_t2_cad_chamfer_corner_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(51)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 35.3, description="plate is 35.3 long along PQ")
scene.constraint.eq(P.distance(S), 31.5, description="plate is 31.5 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 8.6, description="the chamfer takes 8.6 off along edge QR")
scene.constraint.eq(G2.distance(R), 8.6, description="the chamfer takes 8.6 off along edge SR")
scene.constraint.eq(N.x, 16.1, description="the hole centre is 16.1 from the datum edge PS")
scene.constraint.eq(N.y, 12.4, description="the hole centre is 12.4 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 5, description="at least 2.8 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 5, description="at least 2.8 of material between the hole and edge PS")
scene.constraint.geq(N.y, 5, description="at least 2.8 of material between the hole and edge PQ")

the hole radius is half the stated across-size

the chamfer endpoints are each g from the corner R, measured ALONG the edges

the clearance to the chamfer is the perpendicular distance from N to the line G1G2

edge clearance is measured from the hole edge, so it uses clearance + hole radius

G1 and G2 lie on the plate between the named corners, not on the extensions of those edges


A rectangular plate measures 42.9 mm by 24.7 mm. Set up coordinates with the bottom-left corner at the origin P, the 42.9 mm edge running from P along the positive x-direction to Q, and the 24.7 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 9.2 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 5.7 mm across is drilled with its centre N at 16.2 mm from edge PS and 9.1 mm from edge PQ. At least 2.7 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

"""Chamfered corner with a clearance hole

Oracle formalization for cad_t2_cad_chamfer_corner_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(61)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 42.9, description="plate is 42.9 long along PQ")
scene.constraint.eq(P.distance(S), 24.7, description="plate is 24.7 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 9.2, description="the chamfer takes 9.2 off along edge QR")
scene.constraint.eq(G2.distance(R), 9.2, description="the chamfer takes 9.2 off along edge SR")
scene.constraint.eq(N.x, 16.2, description="the hole centre is 16.2 from the datum edge PS")
scene.constraint.eq(N.y, 9.1, description="the hole centre is 9.1 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 5.55, description="at least 2.7 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 5.55, description="at least 2.7 of material between the hole and edge PS")
scene.constraint.geq(N.y, 5.55, description="at least 2.7 of material between the hole and edge PQ")


A rectangular plate measures 39.3 mm by 31.3 mm. Set up coordinates with the bottom-left corner at the origin P, the 39.3 mm edge running from P along the positive x-direction to Q, and the 31.3 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 12.1 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 4.3 mm across is drilled with its centre N at 17.1 mm from edge PS and 10.5 mm from edge PQ. At least 2.6 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

"""Chamfered corner with a clearance hole

Oracle formalization for cad_t2_cad_chamfer_corner_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(56)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 39.3, description="plate is 39.3 long along PQ")
scene.constraint.eq(P.distance(S), 31.3, description="plate is 31.3 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 12.1, description="the chamfer takes 12.1 off along edge QR")
scene.constraint.eq(G2.distance(R), 12.1, description="the chamfer takes 12.1 off along edge SR")
scene.constraint.eq(N.x, 17.1, description="the hole centre is 17.1 from the datum edge PS")
scene.constraint.eq(N.y, 10.5, description="the hole centre is 10.5 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 4.75, description="at least 2.6 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 4.75, description="at least 2.6 of material between the hole and edge PS")
scene.constraint.geq(N.y, 4.75, description="at least 2.6 of material between the hole and edge PQ")


A rectangular plate measures 33.6 mm by 25.1 mm. Set up coordinates with the bottom-left corner at the origin P, the 33.6 mm edge running from P along the positive x-direction to Q, and the 25.1 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 12.6 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 4 mm across is drilled with its centre N at 15.3 mm from edge PS and 13.7 mm from edge PQ. At least 1.6 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

"""Chamfered corner with a clearance hole

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

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

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

scene = GeoScene(49)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 33.6, description="plate is 33.6 long along PQ")
scene.constraint.eq(P.distance(S), 25.1, description="plate is 25.1 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 12.6, description="the chamfer takes 12.6 off along edge QR")
scene.constraint.eq(G2.distance(R), 12.6, description="the chamfer takes 12.6 off along edge SR")
scene.constraint.eq(N.x, 15.3, description="the hole centre is 15.3 from the datum edge PS")
scene.constraint.eq(N.y, 13.7, description="the hole centre is 13.7 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 3.6, description="at least 1.6 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 3.6, description="at least 1.6 of material between the hole and edge PS")
scene.constraint.geq(N.y, 3.6, description="at least 1.6 of material between the hole and edge PQ")


A rectangular plate measures 41.2 mm by 23.3 mm. Set up coordinates with the bottom-left corner at the origin P, the 41.2 mm edge running from P along the positive x-direction to Q, and the 23.3 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 9 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 6.4 mm across is drilled with its centre N at 17.3 mm from edge PS and 10.3 mm from edge PQ. At least 2.1 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

"""Chamfered corner with a clearance hole

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

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

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

scene = GeoScene(59)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 41.2, description="plate is 41.2 long along PQ")
scene.constraint.eq(P.distance(S), 23.3, description="plate is 23.3 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 9, description="the chamfer takes 9 off along edge QR")
scene.constraint.eq(G2.distance(R), 9, description="the chamfer takes 9 off along edge SR")
scene.constraint.eq(N.x, 17.3, description="the hole centre is 17.3 from the datum edge PS")
scene.constraint.eq(N.y, 10.3, description="the hole centre is 10.3 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 5.3, description="at least 2.1 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 5.3, description="at least 2.1 of material between the hole and edge PS")
scene.constraint.geq(N.y, 5.3, description="at least 2.1 of material between the hole and edge PQ")


A rectangular plate measures 32.6 mm by 26.7 mm. Set up coordinates with the bottom-left corner at the origin P, the 32.6 mm edge running from P along the positive x-direction to Q, and the 26.7 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 12.7 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 5.3 mm across is drilled with its centre N at 15.4 mm from edge PS and 11.5 mm from edge PQ. At least 2.4 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

"""Chamfered corner with a clearance hole

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

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

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

scene = GeoScene(47)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 32.6, description="plate is 32.6 long along PQ")
scene.constraint.eq(P.distance(S), 26.7, description="plate is 26.7 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 12.7, description="the chamfer takes 12.7 off along edge QR")
scene.constraint.eq(G2.distance(R), 12.7, description="the chamfer takes 12.7 off along edge SR")
scene.constraint.eq(N.x, 15.4, description="the hole centre is 15.4 from the datum edge PS")
scene.constraint.eq(N.y, 11.5, description="the hole centre is 11.5 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 5.05, description="at least 2.4 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 5.05, description="at least 2.4 of material between the hole and edge PS")
scene.constraint.geq(N.y, 5.05, description="at least 2.4 of material between the hole and edge PQ")


A rectangular plate measures 41.8 mm by 24.7 mm. Set up coordinates with the bottom-left corner at the origin P, the 41.8 mm edge running from P along the positive x-direction to Q, and the 24.7 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 8.3 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 4.8 mm across is drilled with its centre N at 15.8 mm from edge PS and 10.1 mm from edge PQ. At least 3 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

"""Chamfered corner with a clearance hole

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

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

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

scene = GeoScene(59)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 41.8, description="plate is 41.8 long along PQ")
scene.constraint.eq(P.distance(S), 24.7, description="plate is 24.7 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 8.3, description="the chamfer takes 8.3 off along edge QR")
scene.constraint.eq(G2.distance(R), 8.3, description="the chamfer takes 8.3 off along edge SR")
scene.constraint.eq(N.x, 15.8, description="the hole centre is 15.8 from the datum edge PS")
scene.constraint.eq(N.y, 10.1, description="the hole centre is 10.1 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 5.4, description="at least 3 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 5.4, description="at least 3 of material between the hole and edge PS")
scene.constraint.geq(N.y, 5.4, description="at least 3 of material between the hole and edge PQ")


A rectangular plate measures 40.7 mm by 25.5 mm. Set up coordinates with the bottom-left corner at the origin P, the 40.7 mm edge running from P along the positive x-direction to Q, and the 25.5 mm edge running from P along the positive y-direction to S; R is the far corner, diagonally opposite P. The corner at R is chamfered off by a straight cut that takes 8.3 mm off along each of the two edges that meet there: the cut starts at G1, which lies on edge QR, and finishes at G2, which lies on edge SR - both of them on the plate, between the corners named. A hole 6.1 mm across is drilled with its centre N at 14.4 mm from edge PS and 10.7 mm from edge PQ. At least 1.9 mm of material must remain between the hole and the chamfer face, and between the hole and the two datum edges.

"""Chamfered corner with a clearance hole

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

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

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

scene = GeoScene(58)

P, Q, R, S, G1, G2, N = scene.add.points(["P", "Q", "R", "S", "G1", "G2", "N"])

scene.constraint.eq(P.x, 0, description="datum: P is the origin, the datum corner of the plate (x)")
scene.constraint.eq(P.y, 0, description="datum: P is the origin, the datum corner of the plate (y)")
scene.constraint.eq(Q.y, 0, description="datum: edge PQ runs along the x-axis")
scene.constraint.gt(Q.x, 1.0, description="datum: the plate lies in the +x direction from P")
scene.constraint.eq(P.distance(Q), 40.7, description="plate is 40.7 long along PQ")
scene.constraint.eq(P.distance(S), 25.5, description="plate is 25.5 wide along PS")
scene.relate.perpendicular(scene.add.line_segment(P, Q), scene.add.line_segment(P, S))
scene.constraint.gt(S.y, 1.0, description="datum: the plate lies in the +y direction from P")
scene.constraint.eq(R.x, Q.x + S.x - P.x, description="plate corner R closes the rectangle (x)")
scene.constraint.eq(R.y, Q.y + S.y - P.y, description="plate corner R closes the rectangle (y)")
scene.relate.point_lies_on(G1, scene.add.line_segment(Q, R))
scene.relate.point_lies_on(G2, scene.add.line_segment(S, R))
scene.constraint.eq(G1.distance(R), 8.3, description="the chamfer takes 8.3 off along edge QR")
scene.constraint.eq(G2.distance(R), 8.3, description="the chamfer takes 8.3 off along edge SR")
scene.constraint.eq(N.x, 14.4, description="the hole centre is 14.4 from the datum edge PS")
scene.constraint.eq(N.y, 10.7, description="the hole centre is 10.7 from the datum edge PQ")
scene.constraint.geq(cross(G1, G2, N) / G1.distance(G2), 4.95, description="at least 1.9 of material between the hole and the chamfer face")
scene.constraint.geq(N.x, 4.95, description="at least 1.9 of material between the hole and edge PS")
scene.constraint.geq(N.y, 4.95, description="at least 1.9 of material between the hole and edge PQ")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 14.3 mm across, the small end is 8.8 mm across, and the two centres are 30.2 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

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

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 30.2, description="the two round ends are 30.2 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 14.3, description="the large round end is 14.3 across")
scene.constraint.eq(2 * end_D.radius, 8.8, description="the small round end is 8.8 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")

each end radius is half the stated across-size

'runs smoothly into' means each flank is tangent to both end circles

because the two ends have different diameters the flanks are NOT parallel to the line of centres

each tangency point is the foot of the perpendicular from that end's centre onto the flank

'does not cross over' selects the external common tangent, not the internal one

T/V is the upper flank and W/X the lower one


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 19.8 mm across, the small end is 9.5 mm across, and the two centres are 33.3 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

Oracle formalization for cad_t2_cad_dogbone_link_0029. 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(49)

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 33.3, description="the two round ends are 33.3 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 19.8, description="the large round end is 19.8 across")
scene.constraint.eq(2 * end_D.radius, 9.5, description="the small round end is 9.5 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 14.1 mm across, the small end is 9.5 mm across, and the two centres are 36.8 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

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

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 36.8, description="the two round ends are 36.8 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 14.1, description="the large round end is 14.1 across")
scene.constraint.eq(2 * end_D.radius, 9.5, description="the small round end is 9.5 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 17.7 mm across, the small end is 9.6 mm across, and the two centres are 28.9 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

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

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 28.9, description="the two round ends are 28.9 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 17.7, description="the large round end is 17.7 across")
scene.constraint.eq(2 * end_D.radius, 9.6, description="the small round end is 9.6 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 16.8 mm across, the small end is 7.4 mm across, and the two centres are 31.4 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

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

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 31.4, description="the two round ends are 31.4 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 16.8, description="the large round end is 16.8 across")
scene.constraint.eq(2 * end_D.radius, 7.4, description="the small round end is 7.4 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 20 mm across, the small end is 9.7 mm across, and the two centres are 30.5 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

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

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 30.5, description="the two round ends are 30.5 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 20, description="the large round end is 20 across")
scene.constraint.eq(2 * end_D.radius, 9.7, description="the small round end is 9.7 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 18 mm across, the small end is 6 mm across, and the two centres are 37.9 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

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

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 37.9, description="the two round ends are 37.9 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 18, description="the large round end is 18 across")
scene.constraint.eq(2 * end_D.radius, 6, description="the small round end is 6 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 18.3 mm across, the small end is 10 mm across, and the two centres are 29.9 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

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

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 29.9, description="the two round ends are 29.9 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 18.3, description="the large round end is 18.3 across")
scene.constraint.eq(2 * end_D.radius, 10, description="the small round end is 10 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


A flat link is made from two round ends joined by a straight-sided waist. Set up coordinates with the centre of the large round end at the origin C, and the centre of the small round end at D on the positive x-axis. The large end is 16.9 mm across, the small end is 11 mm across, and the two centres are 33.6 mm apart. The waist has two straight flanks. The upper flank runs smoothly into both round ends, touching the large end at T and the small end at V; the lower flank does the same, touching the large end at W and the small end at X. Neither flank crosses over between the two ends - each one stays on its own side of the link.

"""Dogbone link with tangent flanks

Oracle formalization for cad_t2_cad_dogbone_link_0036. 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(49)

C, D, T, V, W, X = scene.add.points(["C", "D", "T", "V", "W", "X"])

scene.constraint.eq(C.x, 0, description="datum: C is the origin, the centre of the large round end (x)")
scene.constraint.eq(C.y, 0, description="datum: C is the origin, the centre of the large round end (y)")
scene.constraint.eq(D.y, 0, description="datum: the line of centres CD runs along the x-axis")
scene.constraint.gt(D.x, 1.0, description="datum: the small end lies in the +x direction from C")
scene.constraint.eq(C.distance(D), 33.6, description="the two round ends are 33.6 apart between centres")
end_C = scene.add.circle(C)
end_D = scene.add.circle(D)
scene.constraint.eq(2 * end_C.radius, 16.9, description="the large round end is 16.9 across")
scene.constraint.eq(2 * end_D.radius, 11, description="the small round end is 11 across")
flank_upper = scene.add.line(T, V)
flank_lower = scene.add.line(W, X)
scene.relate.tangent_to_circle(flank_upper, end_C, T)
scene.relate.tangent_to_circle(flank_upper, end_D, V)
scene.relate.tangent_to_circle(flank_lower, end_C, W)
scene.relate.tangent_to_circle(flank_lower, end_D, X)
scene.constraint.gt(cross(C, D, T), 0.05, description="T is on the upper flank")
scene.constraint.lt(cross(C, D, W), -0.05, description="W is on the lower flank")
scene.constraint.gt(dot(C, T, D, V), 0.05, description="the upper flank does not cross between the ends: it touches both on the same side")
scene.constraint.gt(dot(C, W, D, X), 0.05, description="the lower flank does not cross between the ends: it touches both on the same side")


An L-shaped bracket is cut from 5.9 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 25.2 mm long and the upright outer edge OB is 25 mm long. Both arms are 5.9 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 4.7 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(38)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 25.2, description="bottom outer edge OA is 25.2 long")
scene.constraint.eq(O.distance(B), 25, description="upright outer edge OB is 25 long")
scene.constraint.eq(K.y, 5.9, description="the bottom arm is 5.9 thick, so the inner corner K sits 5.9 above edge OA")
scene.constraint.eq(K.x, 5.9, description="the upright arm is 5.9 thick, so the inner corner K sits 5.9 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 4.7, description="the blend round has radius 4.7")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")

'runs smoothly into' means the round is TANGENT to both inner faces

tangency puts F exactly r from each inner face, i.e. on the bisector of the inner corner

T and U are the feet of the perpendiculars from F onto the two faces

the inner faces are offset from the outer edges by the arm thickness

the round is on the material side of each face, not the outside


An L-shaped bracket is cut from 4.8 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 32.5 mm long and the upright outer edge OB is 19.8 mm long. Both arms are 4.8 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 2.2 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(47)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 32.5, description="bottom outer edge OA is 32.5 long")
scene.constraint.eq(O.distance(B), 19.8, description="upright outer edge OB is 19.8 long")
scene.constraint.eq(K.y, 4.8, description="the bottom arm is 4.8 thick, so the inner corner K sits 4.8 above edge OA")
scene.constraint.eq(K.x, 4.8, description="the upright arm is 4.8 thick, so the inner corner K sits 4.8 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 2.2, description="the blend round has radius 2.2")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


An L-shaped bracket is cut from 7 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 28.3 mm long and the upright outer edge OB is 27.9 mm long. Both arms are 7 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 4.8 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(42)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 28.3, description="bottom outer edge OA is 28.3 long")
scene.constraint.eq(O.distance(B), 27.9, description="upright outer edge OB is 27.9 long")
scene.constraint.eq(K.y, 7, description="the bottom arm is 7 thick, so the inner corner K sits 7 above edge OA")
scene.constraint.eq(K.x, 7, description="the upright arm is 7 thick, so the inner corner K sits 7 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 4.8, description="the blend round has radius 4.8")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


An L-shaped bracket is cut from 5.6 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 28.8 mm long and the upright outer edge OB is 18.5 mm long. Both arms are 5.6 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 2.5 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(42)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 28.8, description="bottom outer edge OA is 28.8 long")
scene.constraint.eq(O.distance(B), 18.5, description="upright outer edge OB is 18.5 long")
scene.constraint.eq(K.y, 5.6, description="the bottom arm is 5.6 thick, so the inner corner K sits 5.6 above edge OA")
scene.constraint.eq(K.x, 5.6, description="the upright arm is 5.6 thick, so the inner corner K sits 5.6 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 2.5, description="the blend round has radius 2.5")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


An L-shaped bracket is cut from 4.5 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 34.7 mm long and the upright outer edge OB is 19.6 mm long. Both arms are 4.5 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 2.6 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(50)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 34.7, description="bottom outer edge OA is 34.7 long")
scene.constraint.eq(O.distance(B), 19.6, description="upright outer edge OB is 19.6 long")
scene.constraint.eq(K.y, 4.5, description="the bottom arm is 4.5 thick, so the inner corner K sits 4.5 above edge OA")
scene.constraint.eq(K.x, 4.5, description="the upright arm is 4.5 thick, so the inner corner K sits 4.5 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 2.6, description="the blend round has radius 2.6")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


An L-shaped bracket is cut from 5.1 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 33.9 mm long and the upright outer edge OB is 19 mm long. Both arms are 5.1 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 3.8 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(49)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 33.9, description="bottom outer edge OA is 33.9 long")
scene.constraint.eq(O.distance(B), 19, description="upright outer edge OB is 19 long")
scene.constraint.eq(K.y, 5.1, description="the bottom arm is 5.1 thick, so the inner corner K sits 5.1 above edge OA")
scene.constraint.eq(K.x, 5.1, description="the upright arm is 5.1 thick, so the inner corner K sits 5.1 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 3.8, description="the blend round has radius 3.8")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


An L-shaped bracket is cut from 4.5 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 26 mm long and the upright outer edge OB is 25.2 mm long. Both arms are 4.5 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 3.3 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(39)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 26, description="bottom outer edge OA is 26 long")
scene.constraint.eq(O.distance(B), 25.2, description="upright outer edge OB is 25.2 long")
scene.constraint.eq(K.y, 4.5, description="the bottom arm is 4.5 thick, so the inner corner K sits 4.5 above edge OA")
scene.constraint.eq(K.x, 4.5, description="the upright arm is 4.5 thick, so the inner corner K sits 4.5 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 3.3, description="the blend round has radius 3.3")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


An L-shaped bracket is cut from 5.7 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 24.2 mm long and the upright outer edge OB is 24 mm long. Both arms are 5.7 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 3.5 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

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

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

scene = GeoScene(36)

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 24.2, description="bottom outer edge OA is 24.2 long")
scene.constraint.eq(O.distance(B), 24, description="upright outer edge OB is 24 long")
scene.constraint.eq(K.y, 5.7, description="the bottom arm is 5.7 thick, so the inner corner K sits 5.7 above edge OA")
scene.constraint.eq(K.x, 5.7, description="the upright arm is 5.7 thick, so the inner corner K sits 5.7 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 3.5, description="the blend round has radius 3.5")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


An L-shaped bracket is cut from 4.1 mm flat plate. Set up coordinates with the outside corner of the L at the origin O, the bottom outer edge running from O along the positive x-direction to A, and the upright outer edge running from O along the positive y-direction to B. The bottom outer edge OA is 28.2 mm long and the upright outer edge OB is 26.5 mm long. Both arms are 4.1 mm thick. The inner face of the bottom arm is the straight edge from the inner corner K out to E at the end of the bottom arm; the inner face of the upright is the straight edge from K up to G at the top of the upright. K is the point where those two inner faces would meet. To relieve the stress raiser there, the inner corner is blended with a 2.9 mm radius round centred at F. The round is cut into the material on the inside of the corner, and it runs smoothly into both inner faces with no step or kink, meeting the bottom inner face at T and the upright inner face at U.

"""Filleted L-bracket inner corner

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

O, A, B, K, E, G, F, T, U = scene.add.points(["O", "A", "B", "K", "E", "G", "F", "T", "U"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the outside corner of the L (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the outside corner of the L (y)")
scene.constraint.eq(A.y, 0, description="datum: the bottom outer edge OA runs along the x-axis")
scene.constraint.gt(A.x, 1.0, description="datum: the bottom arm runs in the +x direction")
scene.constraint.eq(B.x, 0, description="datum: the upright outer edge OB runs along the y-axis")
scene.constraint.gt(B.y, 1.0, description="datum: the upright arm runs in the +y direction")
scene.constraint.eq(O.distance(A), 28.2, description="bottom outer edge OA is 28.2 long")
scene.constraint.eq(O.distance(B), 26.5, description="upright outer edge OB is 26.5 long")
scene.constraint.eq(K.y, 4.1, description="the bottom arm is 4.1 thick, so the inner corner K sits 4.1 above edge OA")
scene.constraint.eq(K.x, 4.1, description="the upright arm is 4.1 thick, so the inner corner K sits 4.1 in from edge OB")
scene.constraint.eq(E.y, K.y, description="inner face KE is parallel to the bottom outer edge")
scene.constraint.eq(E.x, A.x, description="inner face KE ends flush with the end of the bottom arm")
scene.constraint.eq(G.x, K.x, description="inner face KG is parallel to the upright outer edge")
scene.constraint.eq(G.y, B.y, description="inner face KG ends flush with the top of the upright")
face_h = scene.add.line_segment(K, E)
face_v = scene.add.line_segment(K, G)
fillet = scene.add.circle(F)
scene.constraint.eq(fillet.radius, 2.9, description="the blend round has radius 2.9")
scene.relate.tangent_to_circle(face_h, fillet, T)
scene.relate.tangent_to_circle(face_v, fillet, U)
scene.constraint.gt(cross(K, E, F), 0.05, description="the round is cut into the material, on the inner side of face KE")
scene.constraint.gt(cross(G, K, F), 0.05, description="the round is cut into the material, on the inner side of face KG")


A shaft cross-section is a circle 26.1 mm across. A keyway is machined into it: a square-sided notch 8.1 mm wide with a flat bottom. Set up coordinates with the shaft centre at the origin O and the keyway cut symmetrically about the positive y-direction, so that the keyway centreline is the y-axis. The flat bottom of the keyway runs from its left corner K to its right corner L. The two side walls run from those corners out to the shaft surface, breaking out at M above K and at N above L. S is the point on the shaft surface directly opposite the keyway. Measured from the flat bottom of the keyway across to the far side of the shaft at S, the distance is 21.8 mm.

"""Keyway in a shaft cross-section

Oracle formalization for cad_t2_cad_keyway_0037. 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(22)

O, S, K, L, M, N = scene.add.points(["O", "S", "K", "L", "M", "N"])

scene.constraint.eq(O.x, 0, description="datum: O is the origin, the shaft centre (x)")
scene.constraint.eq(O.y, 0, description="datum: O is the origin, the shaft centre (y)")
scene.constraint.eq(K.x + L.x, 0, description="datum: the keyway is cut symmetrically about the y-axis")
scene.constraint.eq(L.x - K.x, 8.1, description="the keyway is 8.1 wide between its two side walls")
scene.constraint.gt(L.x, 0.05, description="L is the right-hand bottom corner and K the left-hand one")
scene.constraint.eq(K.y, L.y, description="the bottom of the keyway is flat and square to the keyway centreline")
shaft = scene.add.circle(O)
scene.constraint.eq(2 * shaft.radius, 26.1, description="the shaft is 26.1 across")
scene.relate.point_lies_on(M, shaft)
scene.relate.point_lies_on(N, shaft)
scene.constraint.eq(M.x, K.x, description="the left side wall runs straight up from K, parallel to the keyway centreline, and breaks out at M on the shaft surface")
scene.constraint.eq(N.x, L.x, description="the right side wall runs straight up from L and breaks out at N on the shaft surface")
scene.constraint.gt(M.y - K.y, 0.05, description="the side walls run upward from the flat bottom to the shaft surface")
scene.constraint.gt(N.y - L.y, 0.05, description="the side walls run upward from the flat bottom to the shaft surface")
scene.relate.point_lies_on(S, shaft)
scene.constraint.eq(S.x, O.x, description="S is the point on the shaft surface directly opposite the keyway")
scene.constraint.lt(S.y, -0.05, description="S is on the far side of the shaft from the keyway")
scene.constraint.eq(K.y - S.y, 21.8, description="from the flat bottom of the keyway across to the far side of the shaft measures 21.8")

the shaft radius is half the stated across-size

the two side walls sit at +/- half the keyway width either side of the centreline

the side walls are parallel to the keyway centreline and the flat bottom is square to it

S is diametrically opposite, so the across measurement equals the bottom height plus the radius

the keyway depth below the shaft surface is the shaft size minus the across measurement

the side walls run UP from the flat bottom to the surface, not down