# No. 409 (Brown 1868): "Proportional compasses used in copying drawings on a given larger or smaller scale. The pivot of compasses is secured in a
# slide which is adjustable in the longitudinal slots of legs, and capable of being secured by a set screw, the dimensions are taken between one pair of
# points and transferred with the other pair, and thus enlarged or diminished in proportion to the relative distances of the points from the pivot. A
# scale is provided on one or both legs to indicate the proportion."
#
# Model (cm, the compasses lying on the drawing, so no gravity). Two slotted legs cross at the pivot, its slide set (screwed fast) 10.7 cm from the
# short points and 13.3 cm from the long points. One leg is held still (the other hand); the hand holding the other leg by its long point moves it
# 2 cm either way across (the one driven joint, its hold a pin at the point), so that leg turns on the pivot and the compasses open and close.
# Two light readouts, each pivoted at one point of the held leg and pinned at the other leg's point, record the gap between the long points and
# between the short points; they carry nothing. Generator: opencode-runs/batch13/gen409.py.
number: 409
slug: proportional-compasses
name: Proportional compasses
brown: "Proportional compasses used in copying drawings on a given larger or smaller scale. The pivot of compasses is secured in a slide which is adjustable in the longitudinal slots of legs, and capable of being secured by a set screw, the dimensions are taken between one pair of points and transferred with the other pair, and thus enlarged or diminished in proportion to the relative distances of the points from the pivot. A scale is provided on one or both legs to indicate the proportion."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 60, duration_s: 10, floor: false, gravity: 0}
bodies:
  - id: leg_a
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#c9b98f"
    pieces:
      - {kind: poly, points: [[-4.9428, 6.9612], [4.5572, -9.4933], [5.9428, -8.6933], [-3.5572, 7.7612]], y: [0.05, 0.45]}   # the leg
      - {kind: poly, points: [[-5.35, 9.2665], [-3.5572, 7.7612], [-4.9428, 6.9612]], y: [0.05, 0.45]}   # its short point
      - {kind: poly, points: [[6.65, -11.5181], [4.5572, -9.4933], [5.9428, -8.6933]], y: [0.05, 0.45]}   # its long point
      - {kind: poly, points: [[-4.0665, 6.5434], [4.5335, -8.3522], [4.9665, -8.1022], [-3.6335, 6.7934]], y: [0.0, 0.05], color: "#5c5244"}   # the slot the pivot's slide is set in
      - {kind: disc, center: [-3.85, 6.6684], radius: 0.5, y: [0.0, 0.05], color: "#5c5244"}
      - {kind: disc, center: [4.75, -8.2272], radius: 0.5, y: [0.0, 0.05], color: "#5c5244"}
      - {kind: poly, points: [[-3.3102, 6.3334], [-3.2702, 6.2641], [-2.8805, 6.4891], [-2.9205, 6.5584]], y: [-0.01, 0.05], color: "#3a3632"}   # the scale of proportions
      - {kind: poly, points: [[-3.0602, 5.9004], [-3.0202, 5.8311], [-2.6305, 6.0561], [-2.6705, 6.1254]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-2.8102, 5.4674], [-2.7702, 5.3981], [-2.3805, 5.6231], [-2.4205, 5.6924]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-2.5602, 5.0344], [-2.5202, 4.9651], [-2.1305, 5.1901], [-2.1705, 5.2594]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-2.3102, 4.6014], [-2.2702, 4.5321], [-1.8805, 4.7571], [-1.9205, 4.8264]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-2.0602, 4.1684], [-2.0202, 4.0991], [-1.6305, 4.3241], [-1.6705, 4.3934]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-1.8102, 3.7353], [-1.7702, 3.6661], [-1.3805, 3.8911], [-1.4205, 3.9603]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-1.5602, 3.3023], [-1.5202, 3.2331], [-1.1305, 3.4581], [-1.1705, 3.5273]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-1.3102, 2.8693], [-1.2702, 2.8], [-0.8805, 3.025], [-0.9205, 3.0943]], y: [-0.01, 0.05], color: "#3a3632"}
      - {kind: poly, points: [[-1.0602, 2.4363], [-1.0202, 2.367], [-0.6305, 2.592], [-0.6705, 2.6613]], y: [-0.01, 0.05], color: "#3a3632"}
  - id: leg_b
    shape: part
    pos: [0, 0, 0]
    density: 8400
    color: "#d4c49a"
    pieces:
      - {kind: poly, points: [[3.5572, 7.7612], [-5.9428, -8.6933], [-4.5572, -9.4933], [4.9428, 6.9612]], y: [-0.45, -0.05]}   # the leg
      - {kind: poly, points: [[5.35, 9.2665], [4.9428, 6.9612], [3.5572, 7.7612]], y: [-0.45, -0.05]}   # its short point
      - {kind: poly, points: [[-6.65, -11.5181], [-5.9428, -8.6933], [-4.5572, -9.4933]], y: [-0.45, -0.05]}   # its long point
      - {kind: poly, points: [[3.6335, 6.7934], [-4.9665, -8.1022], [-4.5335, -8.3522], [4.0665, 6.5434]], y: [-0.5, -0.45], color: "#5c5244"}   # the slot the pivot's slide is set in
      - {kind: disc, center: [3.85, 6.6684], radius: 0.5, y: [-0.5, -0.45], color: "#5c5244"}
      - {kind: disc, center: [-4.75, -8.2272], radius: 0.5, y: [-0.5, -0.45], color: "#5c5244"}
      - {kind: disc, center: [0, 0], radius: 1.1, y: [-0.75, -0.5], color: "#b8a888"}   # the pivot's nut on its slide
      - {kind: disc, center: [0, 0], radius: 0.55, y: [-0.9, -0.75], color: "#8f8a80"}
  - {id: car_h, shape: part, pos: [-6.65, 0, -11.5181], mass: 0.05, pieces: [{kind: rod, from: [-6.65, -3, -11.5181], to: [-6.65, -2.95, -11.5181], radius: 0.05}]}
  - {id: car_hz, shape: part, pos: [-6.65, 0, -11.5181], mount: car_h, mass: 0.05, pieces: [{kind: rod, from: [-6.65, -3, -11.5181], to: [-6.65, -2.95, -11.5181], radius: 0.05}]}
  - {id: rdl_arm, shape: part, pos: [6.65, 0, -11.5181], mass: 0.002, pieces: [{kind: rod, from: [6.65, -3, -11.5181], to: [6.65, -2.95, -11.5181], radius: 0.05}]}
  - {id: rdl_rad, shape: part, pos: [-6.65, 0, -11.5181], mount: rdl_arm, mass: 0.002, pieces: [{kind: rod, from: [-6.65, -3, -11.5181], to: [-6.65, -2.95, -11.5181], radius: 0.05}]}
  - {id: rds_arm, shape: part, pos: [-5.35, 0, 9.2665], mass: 0.002, pieces: [{kind: rod, from: [-5.35, -3, 9.2665], to: [-5.35, -2.95, 9.2665], radius: 0.05}]}
  - {id: rds_rad, shape: part, pos: [5.35, 0, 9.2665], mount: rds_arm, mass: 0.002, pieces: [{kind: rod, from: [5.35, -3, 9.2665], to: [5.35, -2.95, 9.2665], radius: 0.05}]}
pins:
  - {id: pin_h, a: car_hz, b: leg_b, at: [-6.65, 0, -11.5181]}   # the hand's hold on the leg's long point
  - {id: p_rdl, a: rdl_rad, b: leg_b, at: [-6.65, 0, -11.5181]}   # readout at the long point
  - {id: p_rds, a: rds_rad, b: leg_b, at: [5.35, 0, 9.2665]}   # readout at the short point
joints:
  - {id: j_b, type: hinge, body: leg_b, axis: [0, 1, 0], damping: 0.002}   # the leg turning on the pivot
  - {id: j_h, type: slide, body: car_h, axis: [1, 0, 0], damping: 0.01}   # the one driven joint: the hand moving the leg's long point across
  - {id: j_hz, type: slide, body: car_hz, axis: [0, 0, 1], damping: 0.01}   # the hand following the point up and down as it goes round
  - {id: j_vl, type: hinge, body: rdl_arm, axis: [0, 1, 0]}
  - {id: j_dl, type: slide, body: rdl_rad, axis: [-1.0, 0, 0.0]}   # readout: the gap between the long points, less 13.300
  - {id: j_vs, type: hinge, body: rds_arm, axis: [0, 1, 0]}
  - {id: j_ds, type: slide, body: rds_rad, axis: [1.0, 0, 0.0]}   # readout: the gap between the short points, less 10.700
driver: {joint: j_h, kind: velocity, rpm: 0, swing: {amplitude: 0.02, hz: 0.3}, kv: 100, max_torque: 20}
checks:
  - {type: follow, out: j_ds, in: j_dl, expect: 0.8045, tol: 0.01, min_r2: 0.999, settle_s: 1.0, window_s: 6}   # the short points open as the long points open, in proportion 10.7 : 13.3
  - {type: amplitude, joint: j_h, min: 0.008, max: 0.028, sustain: 0.7, settle_s: 1.0, window_s: 6}   # the hand moved the point well
camera: {target: [0, 0, -6.3], position: [0, -80, -6.3], fov: 28}
display:
  output: j_ds
  labels: {j_h: "The hand at the long point (driver)", j_b: "The leg on the pivot", j_dl: "Gap between the long points", j_ds: "Gap between the short points"}
