number: 349
slug: parallel-ruler-jointed-arms
name: Another form of parallel ruler
brown: "Another form of parallel ruler. The arms are jointed in the middle and connected with an intermediate bar, by which means the ends of the ruler, as well as the sides, are kept parallel."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 50, duration_s: 8, floor: false, gravity: 0}
bodies:
  # the paper, and the lower ruler held down on it (the frame), with the lower halves' pivots
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    density: 800
    color: "#b5a27e"
    pieces:
      - {kind: poly, points: [[-13.0000, -6.0000], [25.6000, -6.0000], [25.6000, 19.8043], [-13.0000, 19.8043]], y: [0.5, 0.7], collide: 0, color: "#efe6d2"}
      - {kind: poly, points: [[-9.0000, -2.6000], [21.6000, -2.6000], [21.6000, 3.0000], [-2.8000, 3.0000], [-4.2000, 1.6000], [-9.0000, 1.6000]], y: [-0.3, 0.5], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 0.45, y: [-0.9, -0.3], collide: 0, color: "#6f6a60"}
      - {kind: disc, center: [12.2000, 0.0000], radius: 0.45, y: [-0.9, -0.3], collide: 0, color: "#6f6a60"}
  # the lower half of the left arm, turned on its pivot by the opening ruler
  - id: L1
    shape: part
    pos: [0.0000, 0, 0.0000]
    mount: frame
    density: 8500
    color: "#c2a35a"
    pieces:
      - {kind: poly, points: [[-0.5553, 0.4261], [4.7409, 7.3283], [5.8516, 6.4760], [0.5553, -0.4261]], y: [-0.8, -0.35], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 1.0, y: [-0.8, -0.35], collide: 0}
      - {kind: disc, center: [5.2962, 6.9022], radius: 1.0, y: [-0.8, -0.35], collide: 0}
  # the intermediate bar, on the left arm's middle joint; its eye at the right arm's middle joint
  - id: M
    shape: part
    pos: [5.2962, 0, 6.9022]
    mount: L1
    density: 800
    color: "#a8946e"
    pieces:
      - {kind: poly, points: [[-5.8000, 6.9022], [-3.0000, 9.1022], [20.4000, 9.1022], [20.4000, 4.7022], [-3.0000, 4.7022]], y: [-0.25, 0.45], collide: 0}
      - {kind: band, center: [17.4962, 6.9022], r: [0.42, 0.95], a: [0, 6.2832], y: [-0.3, 0.5], slices: 36, collide: 1}
  # the lower half of the right arm, on its pivot; its middle pin in the bar's eye
  - id: L2
    shape: part
    pos: [12.2000, 0, 0.0000]
    mount: frame
    density: 8500
    color: "#c2a35a"
    pieces:
      - {kind: poly, points: [[11.6447, 0.4261], [16.9409, 7.3283], [18.0516, 6.4760], [12.7553, -0.4261]], y: [-0.8, -0.35], collide: 0}
      - {kind: disc, center: [12.2000, 0.0000], radius: 1.0, y: [-0.8, -0.35], collide: 0}
      - {kind: disc, center: [17.4962, 6.9022], radius: 1.0, y: [-0.8, -0.35], collide: 0}
      - {kind: disc, center: [17.4962, 6.9022], radius: 0.4, y: [-0.8, 0.45], collide: 2, color: "#6f6a60"}
  # the upper halves, on the bar's joints; their pins in the upper ruler's eyes
  - id: U1
    shape: part
    pos: [5.2962, 0, 6.9022]
    mount: M
    density: 8500
    color: "#c2a35a"
    pieces:
      - {kind: poly, points: [[4.7409, 6.4760], [-0.5553, 13.3782], [0.5553, 14.2305], [5.8516, 7.3283]], y: [-1.3, -0.85], collide: 0}
      - {kind: disc, center: [5.2962, 6.9022], radius: 1.0, y: [-1.3, -0.85], collide: 0}
      - {kind: disc, center: [0.0000, 13.8043], radius: 1.0, y: [-1.3, -0.85], collide: 0}
      - {kind: disc, center: [0.0000, 13.8043], radius: 0.4, y: [-1.3, 0.45], collide: 2, color: "#6f6a60"}
  - id: U2
    shape: part
    pos: [17.4962, 0, 6.9022]
    mount: M
    density: 8500
    color: "#c2a35a"
    pieces:
      - {kind: poly, points: [[16.9409, 6.4760], [11.6447, 13.3782], [12.7553, 14.2305], [18.0516, 7.3283]], y: [-1.3, -0.85], collide: 0}
      - {kind: disc, center: [17.4962, 6.9022], radius: 1.0, y: [-1.3, -0.85], collide: 0}
      - {kind: disc, center: [12.2000, 13.8043], radius: 1.0, y: [-1.3, -0.85], collide: 0}
      - {kind: disc, center: [12.2000, 13.8043], radius: 0.4, y: [-1.3, 0.45], collide: 2, color: "#6f6a60"}
  # the upper ruler, drawn straight off the lower one and back by the hand
  - id: T
    shape: part
    pos: [0, 0, 13.8043]
    mount: frame
    density: 800
    color: "#b5a27e"
    pieces:
      - {kind: poly, points: [[-9.0000, 17.0043], [21.6000, 17.0043], [21.6000, 11.2043], [-2.8000, 11.2043], [-4.2000, 12.6043], [-9.0000, 12.6043]], y: [-0.25, 0.45], collide: 0}
      - {kind: band, center: [0.0000, 13.8043], r: [0.42, 0.95], a: [0, 6.2832], y: [-0.3, 0.5], slices: 36, collide: 1}
      - {kind: band, center: [12.2000, 13.8043], r: [0.42, 0.95], a: [0, 6.2832], y: [-0.3, 0.5], slices: 36, collide: 1}
joints:
  # the hand draws the upper ruler straight off the lower and back (the one driven joint)
  - {id: j_z, type: slide, body: T, axis: [0, 0, 1], damping: 0.05, range: [-6, 4]}
  - {id: j_L1, type: hinge, body: L1, axis: [0, -1, 0], damping: 0.002}
  - {id: j_M, type: hinge, body: M, axis: [0, -1, 0], damping: 0.002}
  - {id: j_L2, type: hinge, body: L2, axis: [0, -1, 0], damping: 0.002}
  - {id: j_U1, type: hinge, body: U1, axis: [0, -1, 0], damping: 0.002}
  - {id: j_U2, type: hinge, body: U2, axis: [0, -1, 0], damping: 0.002}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_z, kind: velocity, rpm: 0, swing: {amplitude: 0.025, hz: 0.25}, kv: 50, max_torque: 20}
checks:
  # the lower halves turn together, and the bar, carried on them, keeps square to the rulers ...
  - {type: follow, out: j_L2, in: j_L1, expect: 1.0, tol: 0.03, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  - {type: follow, out: j_M, in: j_L1, expect: -1.0, tol: 0.03, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  # ... and the upper halves open just as far the other way: the arms open alike, so the bar slides out
  # sideways and back while the upper ruler goes straight off the lower one
  - {type: follow, out: j_U1, in: j_L1, expect: -1.0, tol: 0.03, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  - {type: follow, out: j_U2, in: j_L1, expect: -1.0, tol: 0.03, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [6.3, 0, 2.5], position: [6.3, -125, 2.5], fov: 30}
display:
  output: j_L1
  labels: {j_z: "Upper ruler, drawn by the hand (driver)", j_L1: Lower half of left arm, j_M: Intermediate bar, j_L2: Lower half of right arm, j_U1: Upper half of left arm, j_U2: Upper half of right arm}

