# No. 29, Spiral-thread disk and spur-gear (Brown 1868).
#
# "Transmission of rotary motion from one shaft at right angles to another. The spiral thread of
# the disk-wheel drives the spur-gear, moving it the distance of one tooth at every revolution."
#
# Laid out as in the plate (1 unit = 1 cm; the drawing plane is x-z, depth is y): the disk-wheel is
# face-on, radius 14, its disc 1.2 thick (front face y = -1.9 towards the viewer), with the plate's
# hatched hub boss at the centre. Its thread is a raised rib on the face, 0.3 cm thick, standing
# 1.1 out of it (y -3.0..-1.9): a clockwise-winding Archimedean spiral of 1.4 turns, crest radius
# 12.9 inward at 1.5 cm per turn, so wherever the gear sits one or two coils lie under it and the
# hand-over from one coil to the next never leaves a gap. The spur-gear (18 involute teeth, module
# 0.47746, so its tooth pitch 2*pi*4.297/18 = 1.5 cm equals the thread's radial pitch) turns on a
# vertical shaft at page x 12.15 (the middle of the coils it meets), 6.8 in front of the disk; its
# plane is horizontal, so the teeth at its back point straight at the face and their pitch circle
# runs through the middle of the rib. The tooth tips stop 0.13 short of the disc face.
#
# Fully physical. Only the disk's shaft is motor-driven. The gear's teeth (spur option meets_parts)
# touch nothing but the thread. Each disk revolution the coils under the gear move inward one
# pitch, like a rack, and carry the gear's back teeth one tooth: 2*pi/18 rad per 2*pi, a ratio of
# 1/18 = 0.0556. The sign is set by the winding (the gear turns the opposite way: -0.0556).
number: 29
slug: spiral-thread-disk-and-spur-gear
name: Spiral-thread disk and spur-gear
brown: "Transmission of rotary motion from one shaft at right angles to another. The spiral thread of the disk-wheel drives the spur-gear, moving it the distance of one tooth at every revolution."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: CG
  multiccd: true
  duration_s: 12
  floor: false
bodies:
  - id: disk
    shape: part
    pos: [0, 0, 0]
    density: 7800
    color: "#e4d9bf"
    pieces:
      - {kind: disc, center: [0, 0], radius: 14, y: [-1.9, -0.7], collide: 0}      # the wheel's face slab
      - {kind: disc, center: [0, 0], radius: 3.0, y: [-2.7, -0.7], collide: 0}     # the plate's hatched hub boss
      - {kind: rod, from: [0, -2.7, 0], to: [0, 1.5, 0], radius: 0.9, collide: 0}  # the disk's own shaft
      - {kind: poly, points: [[-1.1112, 12.7015], [-1.1373, 13.0003], [0.9077, 12.9808], [0.8868, 12.6815]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[0.8868, 12.6815], [0.9077, 12.9808], [2.9188, 12.6424], [2.8513, 12.3501]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[2.8513, 12.3501], [2.9188, 12.6424], [4.8465, 11.9954], [4.7341, 11.7173]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[4.7341, 11.7173], [4.8465, 11.9954], [6.644, 11.0574], [6.4895, 10.8003]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[6.4895, 10.8003], [6.644, 11.0574], [8.2679, 9.8532], [8.075, 9.6234]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[8.075, 9.6234], [8.2679, 9.8532], [9.6792, 8.4139], [9.4528, 8.2171]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[9.4528, 8.2171], [9.6792, 8.4139], [10.8444, 6.7763], [10.59, 6.6173]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[10.59, 6.6173], [10.8444, 6.7763], [11.7365, 4.9818], [11.4603, 4.8646]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[11.4603, 4.8646], [11.7365, 4.9818], [12.3349, 3.0754], [12.0438, 3.0028]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[12.0438, 3.0028], [12.3349, 3.0754], [12.6268, 1.1047], [12.3279, 1.0785]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[12.3279, 1.0785], [12.6268, 1.1047], [12.6067, -0.8816], [12.3074, -0.8607]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[12.3074, -0.8607], [12.6067, -0.8816], [12.2771, -2.8344], [11.9847, -2.7669]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[11.9847, -2.7669], [12.2771, -2.8344], [11.6477, -4.706], [11.3696, -4.5936]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[11.3696, -4.5936], [11.6477, -4.706], [10.736, -6.4509], [10.4789, -6.2964]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[10.4789, -6.2964], [10.736, -6.4509], [9.566, -8.0268], [9.3361, -7.834]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[9.3361, -7.834], [9.566, -8.0268], [8.1679, -9.3962], [7.9711, -9.1697]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[7.9711, -9.1697], [8.1679, -9.3962], [6.5776, -10.5264], [6.4186, -10.272]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[6.4186, -10.272], [6.5776, -10.5264], [4.8353, -11.3913], [4.718, -11.1151]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[4.718, -11.1151], [4.8353, -11.3913], [2.9847, -11.971], [2.9121, -11.6799]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[2.9121, -11.6799], [2.9847, -11.971], [1.072, -12.2532], [1.0458, -11.9543]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[1.0458, -11.9543], [1.072, -12.2532], [-0.8554, -12.2326], [-0.8345, -11.9334]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-0.8345, -11.9334], [-0.8554, -12.2326], [-2.7501, -11.9117], [-2.6826, -11.6194]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-2.6826, -11.6194], [-2.7501, -11.9117], [-4.5656, -11.3], [-4.4532, -11.0219]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-4.4532, -11.0219], [-4.5656, -11.3], [-6.2577, -10.4146], [-6.1032, -10.1574]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-6.1032, -10.1574], [-6.2577, -10.4146], [-7.7858, -9.2787], [-7.593, -9.0489]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-7.593, -9.0489], [-7.7858, -9.2787], [-9.1131, -7.9219], [-8.8867, -7.7251]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-8.8867, -7.7251], [-9.1131, -7.9219], [-10.2084, -6.3789], [-9.954, -6.2199]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-9.954, -6.2199], [-10.2084, -6.3789], [-11.0461, -4.6887], [-10.7699, -4.5715]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-10.7699, -4.5715], [-11.0461, -4.6887], [-11.6072, -2.894], [-11.3161, -2.8214]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-11.3161, -2.8214], [-11.6072, -2.894], [-11.8796, -1.0393], [-11.5808, -1.0132]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-11.5808, -1.0132], [-11.8796, -1.0393], [-11.8585, 0.8293], [-11.5593, 0.8083]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-11.5593, 0.8083], [-11.8585, 0.8293], [-11.5463, 2.6657], [-11.254, 2.5982]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-11.254, 2.5982], [-11.5463, 2.6657], [-10.9523, 4.4251], [-10.6742, 4.3127]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-10.6742, 4.3127], [-10.9523, 4.4251], [-10.0931, 6.0646], [-9.836, 5.9101]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-9.836, 5.9101], [-10.0931, 6.0646], [-8.9914, 7.5447], [-8.7616, 7.3519]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-8.7616, 7.3519], [-8.9914, 7.5447], [-7.6759, 8.8301], [-7.479, 8.6037]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-7.479, 8.6037], [-7.6759, 8.8301], [-6.1802, 9.8904], [-6.0212, 9.636]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-6.0212, 9.636], [-6.1802, 9.8904], [-4.5422, 10.7009], [-4.425, 10.4247]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-4.425, 10.4247], [-4.5422, 10.7009], [-2.8032, 11.2433], [-2.7307, 10.9522]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-2.7307, 10.9522], [-2.8032, 11.2433], [-1.0066, 11.5061], [-0.9805, 11.2072]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[-0.9805, 11.2072], [-1.0066, 11.5061], [0.8031, 11.4845], [0.7822, 11.1852]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[0.7822, 11.1852], [0.8031, 11.4845], [2.5813, 11.1809], [2.5139, 10.8886]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[2.5139, 10.8886], [2.5813, 11.1809], [4.2846, 10.6047], [4.1722, 10.3265]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[4.1722, 10.3265], [4.2846, 10.6047], [5.8715, 9.7717], [5.717, 9.5145]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[5.717, 9.5145], [5.8715, 9.7717], [7.3037, 8.7042], [7.1109, 8.4743]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[7.1109, 8.4743], [7.3037, 8.7042], [8.5471, 7.4298], [8.3207, 7.233]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[8.3207, 7.233], [8.5471, 7.4298], [9.5724, 5.9814], [9.3179, 5.8225]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[9.3179, 5.8225], [9.5724, 5.9814], [10.3557, 4.3957], [10.0795, 4.2785]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[10.0795, 4.2785], [10.3557, 4.3957], [10.8794, 2.7125], [10.5884, 2.6399]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[10.5884, 2.6399], [10.8794, 2.7125], [11.1325, 0.9739], [10.8336, 0.9478]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[10.8336, 0.9478], [11.1325, 0.9739], [11.1104, -0.7769], [10.8111, -0.756]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[10.8111, -0.756], [11.1104, -0.7769], [10.8155, -2.497], [10.5232, -2.4295]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[10.5232, -2.4295], [10.8155, -2.497], [10.257, -4.1441], [9.9788, -4.0317]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[9.9788, -4.0317], [10.257, -4.1441], [9.4503, -5.6783], [9.1931, -5.5238]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[9.1931, -5.5238], [9.4503, -5.6783], [8.4169, -7.0627], [8.1871, -6.8698]], y: [-3.0, -1.9], collide: 1}
      - {kind: poly, points: [[8.1871, -6.8698], [8.4169, -7.0627], [7.1838, -8.2641], [6.987, -8.0377]], y: [-3.0, -1.9], collide: 1}
  - {id: gear_shaft, shape: assembly, pos: [12.15, -6.8, 0], quat: [0.7071068, 0.7071068, 0, 0], color: "#d8ceba"}
  - id: frame
    shape: frame
    rods:
      - {from: [12.15, -6.8, -9.5], to: [12.15, -6.8, 7.4], radius: 1.1}       # the gear's vertical shaft, as drawn
      - {from: [12.15, -6.8, 6.2], to: [12.15, -6.8, 7.4], radius: 1.6}         # its top collar
      - {from: [12.15, -6.8, -9.5], to: [12.15, -6.8, -8.0], radius: 1.6}     # its bottom collar
joints:
  - {id: j_disk, type: hinge, body: disk, axis: [0, 1, 0], damping: 0.001}
  - {id: j_gear, type: hinge, body: gear_shaft, axis: [0, 1, 0], damping: 0.0001}
# the gear: 18 teeth of module 0.47746 (pitch 1.5), width 2.6, phased so no tooth touches the thread at t=0
spurs:
  - {id: gear, body: gear_shaft, pos: [0, 0, 0], teeth: 18, module: 0.47746, width: 2.6, pressure_angle: 0.3490659, backlash: 0.02, phase: 0.291, quat: [1, 0, 0, 0], density: 7800, color: "#d8ceba", meets_parts: true}
# the standard: the gear's shaft is the fixed vertical rod of the plate, collars drawn
contact: {solref: [0.002, 1.0], solimp: [0.98, 0.99, 0.0002], margin: 0}
driver: {joint: j_disk, kind: velocity, rpm: 20, kv: 6, max_torque: 6}
checks:
  - {type: ratio, out: j_gear, in: j_disk, expect: -0.05556, tol: 0.002, settle_s: 1.5, window_s: 9}
  - {type: penetration, max: 0.0008, settle_s: 0.5}
camera: {target: [0, 0, 0], position: [0, -60, 0], fov: 33}   # the plate's own face-on view
display:
  output: j_gear
  labels: {j_disk: Disk with spiral thread (driver), j_gear: Spur gear}
  proof: {label: Thread pulled off, sub: "the disk's thread stops touching the gear: the disk keeps turning, the gear stops"}