number: 324
slug: compound-parallel-ruler
name: Compound Parallel Ruler
brown: "Compound parallel ruler, composed of two simple rulers, A, A, connected by two crossed arms pivoted together at the middle of their length, each pivoted at one end to one of the rulers, and connected with the other one by a slot and sliding-pin, as shown at B. In this the ends as well as the edges are kept parallel. The principle of construction of the several rulers represented is taken advantage of in the formation of some parts of machinery."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 50, duration_s: 8, floor: false, gravity: 0}
bodies:
  # the paper, and the lower ruler A held down on it (the frame); its slot for the pin of the arm D
  - id: A1
    shape: part
    pos: [0, 0, 0]
    fixed: true
    friction: 0.1
    color: "#c9b68c"
    pieces:
      - {kind: poly, points: [[-4, -4], [29, -4], [29, 18.0363], [-4, 18.0363]], y: [0.7, 0.8], color: "#f4efe2"}
      - {kind: poly, points: [[-1.0000, -1.2000], [14.6000, -1.2000], [14.6000, 1.2000], [-1.0000, 1.2000]], y: [0.2, 0.6], collide: 0}
      - {kind: poly, points: [[14.6000, 0.3200], [20.7000, 0.3200], [20.7000, 1.2000], [14.6000, 1.2000]], y: [0.2, 0.6], collide: 1}
      - {kind: poly, points: [[14.6000, -1.2000], [20.7000, -1.2000], [20.7000, -0.3200], [14.6000, -0.3200]], y: [0.2, 0.6], collide: 1}
      - {kind: poly, points: [[20.7000, -1.2000], [25.0000, -1.2000], [25.0000, 1.2000], [20.7000, 1.2000]], y: [0.2, 0.6], collide: 0}
  # arm E, pivoted to the lower ruler at its left end; its far end carries a pin in the upper ruler's slot
  - id: E
    shape: part
    pos: [2.0000, 0, 0]
    mount: A1
    friction: 0.1
    density: 7800
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [2.0000, -0.25, 0], to: [17.9727, -0.25, 12.0363], radius: 0.35, collide: 0}
      - {kind: disc, center: [2.0000, 0], radius: 0.45, y: [-0.45, 0.2], collide: 0, color: "#6f6a60"}
      - {kind: disc, center: [17.9727, 12.0363], radius: 0.3, y: [-1.45, -0.25], collide: 2, color: "#6f6a60"}
  # arm D, pivoted to E at the middle of both; its lower end carries a pin in the lower ruler's slot
  - id: D
    shape: part
    pos: [9.9864, 0, 6.0182]
    mount: E
    friction: 0.1
    density: 7800
    color: "#9c8f78"
    pieces:
      - {kind: rod, from: [2.0000, -0.65, 12.0363], to: [17.9727, -0.65, 0], radius: 0.35, collide: 0}
      - {kind: disc, center: [9.9864, 6.0182], radius: 0.45, y: [-0.9, -0.1], collide: 0, color: "#6f6a60"}
      - {kind: disc, center: [17.9727, 0], radius: 0.3, y: [-0.65, 0.65], collide: 2, color: "#6f6a60"}
  # the upper ruler A, pivoted to D's upper end at its left end; its slot takes E's pin
  - id: A2
    shape: part
    pos: [2.0000, 0, 12.0363]
    mount: D
    friction: 0.1
    density: 700
    color: "#d8c9a3"
    pieces:
      - {kind: poly, points: [[-1.0000, 10.8363], [14.6000, 10.8363], [14.6000, 13.2363], [-1.0000, 13.2363]], y: [-1.4, -1.0], collide: 0}
      - {kind: poly, points: [[14.6000, 12.3563], [20.7000, 12.3563], [20.7000, 13.2363], [14.6000, 13.2363]], y: [-1.4, -1.0], collide: 1}
      - {kind: poly, points: [[14.6000, 10.8363], [20.7000, 10.8363], [20.7000, 11.7163], [14.6000, 11.7163]], y: [-1.4, -1.0], collide: 1}
      - {kind: poly, points: [[20.7000, 10.8363], [25.0000, 10.8363], [25.0000, 13.2363], [20.7000, 13.2363]], y: [-1.4, -1.0], collide: 0}
      - {kind: disc, center: [2.0000, 12.0363], radius: 0.45, y: [-1.5, -0.85], collide: 0, color: "#6f6a60"}
joints:
  # the hand opens and closes the ruler, turning arm E on its pivot (the one driven joint)
  - {id: j_E, type: hinge, body: E, axis: [0, -1, 0], damping: 0.001}
  - {id: j_D, type: hinge, body: D, axis: [0, -1, 0], damping: 0.05}
  - {id: j_A, type: hinge, body: A2, axis: [0, -1, 0], damping: 0.05}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_E, kind: velocity, rpm: 0, swing: {amplitude: 0.2, hz: 0.25}, kv: 50, max_torque: 20}
checks:
  # The arms open like scissors: as E turns by θ, D turns the other way on it by 2θ (its own angle on the
  # paper is −θ) ...
  - {type: ratio, out: j_D, in: j_E, expect: -2.0, tol: 0.04, settle_s: 0.5, window_s: 7.0}
  # ... and the upper ruler turns back on D by θ, so it ends where it started: its edges stay parallel to
  # the lower ruler's (E + D + A = 0, within the pins' play in the slots)
  - {type: ratio, out: j_A, in: j_E, expect: 1.0, tol: 0.03, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [12, 0, 1.5], position: [12, -110, 1.5], fov: 30}
display:
  output: j_A
  labels: {j_E: "Arm E, turned by the hand (driver)", j_D: Arm D on E, j_A: Upper ruler on D}

