# No. 410 (Brown 1868): "Bisecting gauge. Of two parallel cheeks on the cross-bar one is fixed and the other adjustable, and held by thumb-screw. In
# either cheek is centered one of two short bars of equal length, united by a pivot, having a sharp point for marking. This point is always in a
# central position between the cheeks, whatever their distance apart, so that any parallel sided solid to which the cheeks are adjusted may be
# bisected from end to end by drawing the gauge along it. Solids not parallel sided may be bisected in like manner, by leaving one cheek loose, but
# keeping it in contact with solid."
#
# Model (cm, z up, Brown's view from above and in front; no gravity: the hand carries the gauge). The second use: a solid not parallel sided
# (its width 12 cm, widening 0.2 cm per cm along it). The fixed cheek is drawn along the solid's straight side (the gauge on a slide along it: the
# hand drawing the gauge along is the one driven joint, 8 cm either way). The other cheek is left loose on the cross-bar and kept against the
# tapering side (real contact) by the hand (a light spring, 30 N/m). In each cheek is centred a short bar (9 cm), the two united by a pivot at
# the marking point (a pin), so the point keeps midway between the cheeks however far apart they are, and runs along the solid's middle line.
# A light readout pinned at the point records how far it is from the fixed cheek; it carries nothing. Generator: opencode-runs/batch13/gen410.py.
number: 410
slug: bisecting-gauge
name: Bisecting gauge
brown: "Bisecting gauge. Of two parallel cheeks on the cross-bar one is fixed and the other adjustable, and held by thumb-screw. In either cheek is centered one of two short bars of equal length, united by a pivot, having a sharp point for marking. This point is always in a central position between the cheeks, whatever their distance apart, so that any parallel sided solid to which the cheeks are adjusted may be bisected from end to end by drawing the gauge along it. Solids not parallel sided may be bisected in like manner, by leaving one cheek loose, but keeping it in contact with solid."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 60, duration_s: 10, floor: false, gravity: 0}
bodies:
  - id: solid
    shape: part
    pos: [0, 0, 0]
    fixed: true
    friction: 0.05
    color: "#d9c7a0"
    pieces:
      - {kind: loft, a: [[0.0, -17.0, -3.0], [8.6, -17.0, -3.0], [15.4, 17.0, -3.0], [0.0, 17.0, -3.0]], b: [[0.0, -17.0, 0.0], [8.6, -17.0, 0.0], [15.4, 17.0, 0.0], [0.0, 17.0, 0.0]], collide: 1}   # the solid, not parallel sided
      - {kind: loft, a: [[4.25, -17.0, 0.0], [4.35, -17.0, 0.0], [7.75, 17.0, 0.0], [7.65, 17.0, 0.0]], b: [[4.25, -17.0, 0.02], [4.35, -17.0, 0.02], [7.75, 17.0, 0.02], [7.65, 17.0, 0.02]], color: "#3a3632"}   # its middle line
  - id: gauge
    shape: part
    pos: [0, 0, 0]
    density: 700
    color: "#c9a774"
    pieces:
      - {kind: loft, a: [[-3.0, -0.6, 1.6], [18.9, -0.6, 1.6], [18.9, 0.6, 1.6], [-3.0, 0.6, 1.6]], b: [[-3.0, -0.6, 2.8], [18.9, -0.6, 2.8], [18.9, 0.6, 2.8], [-3.0, 0.6, 2.8]]}   # the cross-bar
      - {kind: loft, a: [[-2.5, -2.0, -2.5], [0.0, -2.0, -2.5], [0.0, 2.0, -2.5], [-2.5, 2.0, -2.5]], b: [[-2.5, -2.0, 3.4], [0.0, -2.0, 3.4], [0.0, 2.0, 3.4], [-2.5, 2.0, 3.4]]}   # the fixed cheek, along the solid's straight side
  - id: cheek
    shape: part
    pos: [12.4, 0, 0]
    mount: gauge
    density: 700
    friction: 0.05
    color: "#c9a774"
    pieces:
      - {kind: loft, a: [[12.4, -2.0, -2.5], [14.9, -2.0, -2.5], [14.9, 2.0, -2.5], [12.4, 2.0, -2.5]], b: [[12.4, -2.0, 3.4], [14.9, -2.0, 3.4], [14.9, 2.0, 3.4], [12.4, 2.0, 3.4]], collide: 2}   # the loose cheek, against the tapering side
      - {kind: rod, from: [13.65, 0.0, 3.4], to: [13.65, 0.0, 4.3], radius: 0.22, color: "#8f8a80"}   # its thumb-screw
      - {kind: rod, from: [13.65, 0.0, 4.3], to: [13.65, 0.0, 4.7], radius: 0.6, color: "#8f8a80"}
  - id: bar1
    shape: part
    pos: [-0.6, 0.0, 0.3]
    mount: gauge
    density: 8400
    color: "#b8a888"
    pieces:
      - {kind: loft, a: [[-0.9275, -0.3778, 0.3], [5.8725, -6.2735, 0.3], [6.5275, -5.518, 0.3], [-0.2725, 0.3778, 0.3]], b: [[-0.9275, -0.3778, 0.9], [5.8725, -6.2735, 0.9], [6.5275, -5.518, 0.9], [-0.2725, 0.3778, 0.9]]}   # a short bar, centred in the fixed cheek
      - {kind: rod, from: [6.2, -5.8958, 0.02], to: [6.2, -5.8958, 0.3], radius: 0.12, color: "#3a3632"}   # the sharp point for marking
  - id: bar2
    shape: part
    pos: [13.0, 0.0, 0.3]
    mount: cheek
    density: 8400
    color: "#b8a888"
    pieces:
      - {kind: loft, a: [[12.6725, 0.3778, 0.9], [5.8725, -5.518, 0.9], [6.5275, -6.2735, 0.9], [13.3275, -0.3778, 0.9]], b: [[12.6725, 0.3778, 1.5], [5.8725, -5.518, 1.5], [6.5275, -6.2735, 1.5], [13.3275, -0.3778, 1.5]]}   # the other, centred in the loose cheek
      - {kind: rod, from: [6.2, -5.8958, 0.9], to: [6.2, -5.8958, 2.0], radius: 0.55, color: "#8f8a80"}   # the pivot uniting them
  - {id: rd_x, shape: part, pos: [6.2, -5.8958, 0.6], mass: 0.002, pieces: [{kind: rod, from: [6.2, -5.8958, -6], to: [6.2, -5.8958, -5.95], radius: 0.05}]}
  - {id: rd_y, shape: part, pos: [6.2, -5.8958, 0.6], mount: rd_x, mass: 0.002, pieces: [{kind: rod, from: [6.2, -5.8958, -6], to: [6.2, -5.8958, -5.95], radius: 0.05}]}
pins:
  - {id: pin_p, a: bar1, b: bar2, at: [6.2, -5.8958, 0.9]}   # the pivot uniting the bars, at the point
  - {id: p_rd, a: rd_y, b: bar1, at: [6.2, -5.8958, 0.6]}   # readout at the point
joints:
  - {id: j_g, type: slide, body: gauge, axis: [0, 1, 0], damping: 0.01}   # the one driven joint: the hand drawing the gauge along the solid
  - {id: j_c, type: slide, body: cheek, axis: [1, 0, 0], stiffness: 30, springref: -3, damping: 0.5}   # the loose cheek on the cross-bar, kept against the solid
  - {id: j_1, type: hinge, body: bar1, axis: [0, 0, 1], damping: 0.001}
  - {id: j_2, type: hinge, body: bar2, axis: [0, 0, 1], damping: 0.001}
  - {id: j_px, type: slide, body: rd_x, axis: [1, 0, 0]}   # readout: the point's distance from the fixed cheek, less 6.200
  - {id: j_py, type: slide, body: rd_y, axis: [0, 1, 0]}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_g, kind: velocity, rpm: 0, swing: {amplitude: 0.08, hz: 0.3}, kv: 400, max_torque: 30}
checks:
  - {type: follow, out: j_px, in: j_c, expect: 0.5, tol: 0.01, min_r2: 0.999, settle_s: 1.0, window_s: 6}   # the point keeps midway between the cheeks
  - {type: follow, out: j_c, in: j_g, expect: 0.2, tol: 0.01, min_r2: 0.995, settle_s: 1.0, window_s: 6}   # the loose cheek keeps to the tapering side
  - {type: amplitude, joint: j_g, min: 0.032, max: 0.112, sustain: 0.7, settle_s: 1.0, window_s: 6}
  - {type: penetration, max: 0.004, settle_s: 0.5}
camera: {target: [6, -2, -5], position: [40, -25, 40], fov: 32}
display:
  output: j_px
  labels: {j_g: "The hand drawing the gauge along (driver)", j_c: "The loose cheek on the cross-bar", j_px: "The marking point across the solid"}
