# No. 367 (Brown 1868): "A parallel ruler with which lines may be drawn at required distances apart without setting out. Lower edge of upper blade has a graduated ivory scale, on which the incidence of the outer edge of the brass arc indicates the width between blades."
#
# Reading of the figure (cm, no gravity; a plan of the ruler on the paper): the lower blade lies still on the paper; two equal links,
# 8 cm between centres, are pivoted on its centre-line 14 cm apart and carry the upper blade at their other ends, so the blades and
# links make a parallelogram and the upper blade stays parallel to the lower as it is opened and closed. The one driven joint is the near
# link, rocked by the hand 0.4 rad each way about 60 degrees at 0.2 Hz. A brass arc, struck from the near link's
# lower pivot, is screwed to the lower blade; the lower edge of the upper blade carries an ivory scale, and where the arc's outer edge
# crosses it reads the width between the blades. Generator: opencode-runs/batch12/gen367.py.
number: 367
slug: parallel-ruler
name: Parallel ruler with a scale
brown: "A parallel ruler with which lines may be drawn at required distances apart without setting out. Lower edge of upper blade has a graduated ivory scale, on which the incidence of the outer edge of the brass arc indicates the width between blades."
units: cm
sim:
  timestep: 0.0005
  integrator: implicitfast
  iterations: 100
  solver: PGS
  duration_s: 15.5
  floor: false
  gravity: 0
bodies:
  - id: lower_blade
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#4a3b2c"
    pieces:
      - {kind: poly, points: [[-15.0000, -2.4000], [15.0000, -2.4000], [15.0000, 0.0000], [-15.0000, 0.0000]], y: [0.3, 0.7], collide: 0, color: "#3f3226"}
      - {kind: poly, points: [[-24.0000, -6.0000], [26.0000, -6.0000], [26.0000, 14.0000], [-24.0000, 14.0000]], y: [0.7, 0.75], collide: 0, color: "#efe6d2"}
      - {kind: poly, points: [[0.4769, -0.5373], [0.4240, -0.0011], [0.3409, 0.5312], [0.2277, 1.0580], [0.0849, 1.5775], [-0.0872, 2.0881], [-0.2879, 2.5881], [-0.5167, 3.0759], [-0.7728, 3.5500], [-1.0553, 4.0088], [-1.3634, 4.4508], [-1.6960, 4.8747], [-2.0521, 5.2790], [-2.4306, 5.6625], [-2.8302, 6.0239], [-3.2497, 6.3620], [-3.6877, 6.6759], [-4.1427, 6.9644], [-4.6134, 7.2266], [-5.0982, 7.4617], [-5.5955, 7.6690], [-6.1038, 7.8478], [-6.6214, 7.9974], [-7.1466, 8.1175], [-7.6779, 8.2075], [-7.7544, 7.6629], [-7.2539, 7.5780], [-6.7591, 7.4649], [-6.2715, 7.3239], [-5.7926, 7.1555], [-5.3241, 6.9603], [-4.8673, 6.7387], [-4.4239, 6.4917], [-3.9952, 6.2199], [-3.5826, 5.9242], [-3.1874, 5.6056], [-2.8110, 5.2652], [-2.4544, 4.9039], [-2.1189, 4.5230], [-1.8055, 4.1237], [-1.5152, 3.7072], [-1.2491, 3.2750], [-1.0078, 2.8284], [-0.7923, 2.3688], [-0.6032, 1.8977], [-0.4411, 1.4167], [-0.3065, 0.9273], [-0.1999, 0.4310], [-0.1216, -0.0705], [-0.0718, -0.5757]], y: [0.1, 0.3], collide: 0, color: "#c8a04a"}
      - {kind: rod, from: [0.1791, 0.05, -0.2808], to: [0.1791, 0.3, -0.2808], radius: 0.18, collide: 0, color: "#8f7a3e"}
      - {kind: rod, from: [-9.0000, -0.75, -1.2000], to: [-9.0000, 0.3, -1.2000], radius: 0.35, collide: 0, color: "#b8a26a"}
      - {kind: rod, from: [5.0000, -0.75, -1.2000], to: [5.0000, 0.3, -1.2000], radius: 0.35, collide: 0, color: "#b8a26a"}
  - id: link_a
    shape: part
    pos: [-9.0000, 0, -1.2000]
    mass: 0.05
    color: "#b8a26a"
    pieces:
      - {kind: poly, points: [[-9.4763, -0.9250], [-8.5237, -1.4750], [-4.5237, 5.4532], [-5.4763, 6.0032]], y: [-0.55, -0.4], collide: 0, color: "#b8a26a"}
      - {kind: disc, center: [-9.0000, -1.2000], radius: 0.55, y: [-0.55, -0.4], collide: 0, color: "#b8a26a"}
      - {kind: disc, center: [-5.0000, 5.7282], radius: 0.55, y: [-0.55, -0.4], collide: 0, color: "#b8a26a"}
  - id: link_b
    shape: part
    pos: [5.0000, 0, -1.2000]
    mass: 0.05
    color: "#b8a26a"
    pieces:
      - {kind: poly, points: [[4.5237, -0.9250], [5.4763, -1.4750], [9.4763, 5.4532], [8.5237, 6.0032]], y: [-0.55, -0.4], collide: 0, color: "#b8a26a"}
      - {kind: disc, center: [5.0000, -1.2000], radius: 0.55, y: [-0.55, -0.4], collide: 0, color: "#b8a26a"}
      - {kind: disc, center: [9.0000, 5.7282], radius: 0.55, y: [-0.55, -0.4], collide: 0, color: "#b8a26a"}
  - id: upper_blade
    shape: part
    pos: [-5.0000, 0, 5.7282]
    mount: link_a
    mass: 0.15
    color: "#4a3b2c"
    pieces:
      - {kind: poly, points: [[-16.0000, 4.5282], [14.0000, 4.5282], [14.0000, 6.9282], [-16.0000, 6.9282]], y: [-0.1, 0.3], collide: 0, color: "#3f3226"}
      - {kind: poly, points: [[-3.9000, 4.5282], [2.6000, 4.5282], [2.6000, 5.4282], [-3.9000, 5.4282]], y: [-0.12, -0.1], collide: 0, color: "#eee6cf"}
      - {kind: poly, points: [[-3.6400, 4.5282], [-3.5600, 4.5282], [-3.5600, 5.2782], [-3.6400, 5.2782]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[-3.1400, 4.5282], [-3.0600, 4.5282], [-3.0600, 4.9282], [-3.1400, 4.9282]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[-2.6400, 4.5282], [-2.5600, 4.5282], [-2.5600, 5.2782], [-2.6400, 5.2782]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[-2.1400, 4.5282], [-2.0600, 4.5282], [-2.0600, 4.9282], [-2.1400, 4.9282]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[-1.6400, 4.5282], [-1.5600, 4.5282], [-1.5600, 5.2782], [-1.6400, 5.2782]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[-1.1400, 4.5282], [-1.0600, 4.5282], [-1.0600, 4.9282], [-1.1400, 4.9282]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[-0.6400, 4.5282], [-0.5600, 4.5282], [-0.5600, 5.2782], [-0.6400, 5.2782]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[-0.1400, 4.5282], [-0.0600, 4.5282], [-0.0600, 4.9282], [-0.1400, 4.9282]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[0.3600, 4.5282], [0.4400, 4.5282], [0.4400, 5.2782], [0.3600, 5.2782]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[0.8600, 4.5282], [0.9400, 4.5282], [0.9400, 4.9282], [0.8600, 4.9282]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[1.3600, 4.5282], [1.4400, 4.5282], [1.4400, 5.2782], [1.3600, 5.2782]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[1.8600, 4.5282], [1.9400, 4.5282], [1.9400, 4.9282], [1.8600, 4.9282]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: poly, points: [[2.3600, 4.5282], [2.4400, 4.5282], [2.4400, 5.2782], [2.3600, 5.2782]], y: [-0.16, -0.12], collide: 0, color: "#3b342a"}
      - {kind: rod, from: [-5.0000, -0.75, 5.7282], to: [-5.0000, -0.1, 5.7282], radius: 0.35, collide: 0, color: "#b8a26a"}
      - {kind: rod, from: [9.0000, -0.75, 5.7282], to: [9.0000, -0.1, 5.7282], radius: 0.35, collide: 0, color: "#b8a26a"}
joints:
  - {id: j_a, type: hinge, body: link_a, axis: [0, -1, 0], damping: 0.001}   # the one driven joint: the near link, rocked by the hand
  - {id: j_b, type: hinge, body: link_b, axis: [0, -1, 0], damping: 0.001}
  - {id: j_u, type: hinge, body: upper_blade, axis: [0, -1, 0], damping: 0.001}
pins:
  - {"id": "pin_b", "a": "upper_blade", "b": "link_b", "at": [9.0000, 0, 5.7282]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_a, kind: velocity, rpm: 0, swing: {amplitude: 0.4, hz: 0.2}, kv: 2.0, max_torque: 20}
checks:
  - {type: follow, out: j_b, in: j_a, expect: 1.0, tol: 0.01, min_r2: 0.999, settle_s: 0.5, window_s: 14.5}
  - {type: follow, out: j_u, in: j_a, expect: -1.0, tol: 0.01, min_r2: 0.999, settle_s: 0.5, window_s: 14.5}
  - {type: amplitude, joint: j_a, min: 0.360, max: 0.440, settle_s: 0.5, window_s: 14.5}
camera: {target: [1.0, 0, 1.0], position: [1.0, -95.0, 1.0], fov: 34}
display:
  output: j_u
  labels: {j_a: "Near link (driver, by hand)", j_b: "Far link", j_u: "Upper blade (turn)"}

