# No. 246 (Brown 1868): "Represents a pantograph for copying, enlarging, and reducing plans, etc. One arm is attached to and turns on the fixed
# point, C. B is an ivory tracing-point, and A the pencil. Arranged as shown, if we trace the lines of a plan with the point, B, the pencil will
# reproduce it double the size."
#
# Model (cm, a plan view: the instrument lies flat on the table, so no gravity): the long arm from the fixed point C to the elbow, the long arm
# from the pencil A to the elbow, and the two short arms from the tracing-point B to the middles of the long ones: a parallelogram, with C, B and
# A in line and CA = 2 CB. The hand traces a plan with B: a circle of radius 3 round a template (a crank carrying B, the one driven joint, at
# 12 rev/min). Two drawing-board readouts (light carriages sliding along x and up the board, pinned at B and at A) record where the point and
# the pencil are; they carry nothing. Generator: opencode-runs/batch11/gen246.py.
number: 246
slug: pantograph
name: A pantograph for copying, enlarging and reducing plans
brown: "Represents a pantograph for copying, enlarging, and reducing plans, etc. One arm is attached to and turns on the fixed point, C. B is an ivory tracing-point, and A the pencil. Arranged as shown, if we trace the lines of a plan with the point, B, the pencil will reproduce it double the size."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 60, duration_s: 10.5, floor: false, gravity: 0}
bodies:
  - id: arm_c
    shape: part
    pos: [0.0, 0, 0.0]
    density: 900
    color: "#cdbf9f"
    pieces:
      - {kind: poly, points: [[0.1847, -0.4104], [-0.1847, 0.4104], [39.8153, 18.4104], [40.1847, 17.5896]], y: [0, 0.5]}   # the arm on the fixed point C, to the elbow
      - {kind: disc, center: [0.0, 0.0], radius: 0.8, inner: 0.3, y: [-0.6, 1.6], color: "#6f675b"}
      - {kind: disc, center: [20.0, 9.0], radius: 0.8, inner: 0.3, y: [-0.1, 1.2], color: "#8f8a80"}
      - {kind: disc, center: [0.0, 0.0], radius: 2.0, y: [1.6, 2.6], color: "#6f675b"}   # the fixed point's weight
  - id: arm_a
    shape: part
    pos: [40.0, 0, 18.0]
    mount: arm_c
    density: 900
    color: "#cdbf9f"
    pieces:
      - {kind: poly, points: [[-0.1847, 35.5896], [0.1847, 36.4104], [40.1847, 18.4104], [39.8153, 17.5896]], y: [0.6, 1.1]}   # the pencil's arm, to the elbow
      - {kind: disc, center: [40.0, 18.0], radius: 0.8, inner: 0.3, y: [-0.1, 1.2], color: "#8f8a80"}
      - {kind: disc, center: [20.0, 27.0], radius: 0.8, inner: 0.3, y: [0.5, 1.8], color: "#8f8a80"}
      - {kind: poly, points: [[-1.8255, 37.8214], [0.0255, 38.5786], [1.8255, 34.1786], [-0.0255, 33.4214]], y: [-0.2, 1.9], color: "#5c5244"}   # the pencil's holder
      - {kind: rod, from: [0.0, -1.2, 36.0], to: [0.0, 0.6, 36.0], radius: 0.3, color: "#3a3632"}   # the pencil A
  - id: arm_bu
    shape: part
    pos: [20.0, 0, 27.0]
    mount: arm_a
    density: 900
    color: "#cdbf9f"
    pieces:
      - {kind: poly, points: [[0.1847, 17.5896], [-0.1847, 18.4104], [19.8153, 27.4104], [20.1847, 26.5896]], y: [1.2, 1.7]}
  - id: arm_bl
    shape: part
    pos: [20.0, 0, 9.0]
    mount: arm_c
    density: 900
    color: "#cdbf9f"
    pieces:
      - {kind: poly, points: [[-0.1847, 17.5896], [0.1847, 18.4104], [20.1847, 9.4104], [19.8153, 8.5896]], y: [0.6, 1.1]}
      - {kind: disc, center: [0.0, 18.0], radius: 0.8, inner: 0.3, y: [0.5, 1.8], color: "#8f8a80"}
      - {kind: rod, from: [0.0, -1.2, 18.0], to: [0.0, 0.6, 18.0], radius: 0.3, color: "#efe8d8"}   # the ivory tracing-point B
  - id: template
    shape: part
    pos: [3.0, 0, 18.0]
    mass: 0.05
    color: "#9c958a"
    pieces:
      - {kind: disc, center: [3.0, 18.0], radius: 3.15, inner: 2.85, y: [-1.6, -1.4], color: "#b9b09c"}   # the plan's line traced
      - {kind: poly, points: [[3.0, 18.2], [3.0, 17.8], [0.0, 17.8], [0.0, 18.2]], y: [-1.4, -1.2], color: "#8f8a80"}   # the hand's guide round it
  - {id: tr_x, shape: part, pos: [0.0, 0, 18.0], mass: 0.002, pieces: [{kind: rod, from: [0.0, -2, 18.0], to: [0.0, -1.95, 18.0], radius: 0.05}]}
  - {id: tr_z, shape: part, pos: [0.0, 0, 18.0], mount: tr_x, mass: 0.002, pieces: [{kind: rod, from: [0.0, -2, 18.0], to: [0.0, -1.95, 18.0], radius: 0.05}]}
  - {id: pen_x, shape: part, pos: [0.0, 0, 36.0], mass: 0.002, pieces: [{kind: rod, from: [0.0, -2, 36.0], to: [0.0, -1.95, 36.0], radius: 0.05}]}
  - {id: pen_z, shape: part, pos: [0.0, 0, 36.0], mount: pen_x, mass: 0.002, pieces: [{kind: rod, from: [0.0, -2, 36.0], to: [0.0, -1.95, 36.0], radius: 0.05}]}
pins:
  - {id: p_b, a: arm_bu, b: arm_bl, at: [0.0, 0, 18.0]}   # the short arms' joint at the tracing-point
  - {id: p_hand, a: template, b: arm_bl, at: [0.0, 0, 18.0]}   # the hand holds B on the plan's line
  - {id: p_trace, a: tr_z, b: arm_bl, at: [0.0, 0, 18.0]}   # readouts
  - {id: p_pen, a: pen_z, b: arm_a, at: [0.0, 0, 36.0]}
joints:
  - {id: j_c, type: hinge, body: arm_c, axis: [0, -1, 0], damping: 0.001}
  - {id: j_elbow, type: hinge, body: arm_a, axis: [0, -1, 0], damping: 0.001}
  - {id: j_up, type: hinge, body: arm_bu, axis: [0, -1, 0], damping: 0.001}
  - {id: j_low, type: hinge, body: arm_bl, axis: [0, -1, 0], damping: 0.001}
  - {id: j_hand, type: hinge, body: template, axis: [0, -1, 0], damping: 0.001}   # the one driven joint: B carried round the plan's line
  - {id: j_bx, type: slide, body: tr_x, axis: [1, 0, 0]}
  - {id: j_bz, type: slide, body: tr_z, axis: [0, 0, 1]}
  - {id: j_ax, type: slide, body: pen_x, axis: [1, 0, 0]}
  - {id: j_az, type: slide, body: pen_z, axis: [0, 0, 1]}
driver: {joint: j_hand, kind: velocity, rpm: 12, kv: 1, max_torque: 5}
checks:
  - {type: follow, out: j_ax, in: j_bx, expect: 2.0, tol: 0.02, min_r2: 0.999, settle_s: 0.5, window_s: 9.5}   # the pencil copies B's motion across the board, double
  - {type: follow, out: j_az, in: j_bz, expect: 2.0, tol: 0.02, min_r2: 0.999, settle_s: 0.5, window_s: 9.5}   # and up it
  - {type: turning, joint: j_hand, direction: 1, min_mean: 1.131, slow: 0.5, min_fraction: 0.95, settle_s: 0.5, window_s: 9.5}
camera: {target: [20, 0, 18], position: [20, -125, 18], fov: 30}
display:
  output: j_ax
  labels: {j_hand: "Tracing-point B led round the plan (driver)", j_c: "Arm on the fixed point C", j_bx: "B across the board", j_bz: "B up the board", j_ax: "Pencil A across", j_az: "Pencil A up"}

