# No. 368 (Brown 1868): "Describing spiral line on a cylinder. The spur-gear which drives the bevel-gears, and thus gives rotary motion to the cylinder, also gears into the toothed rack, and thereby causes the marking point to traverse from end to end of the cylinder."
#
# Reading of the figure (cm, gravity on; Brown's elevation): a cross-shaft above the table carries the crank (right), the spur-gear
# (20 teeth, module 0.35) and, at its left end, a bevel-gear of 20 teeth working an equal horizontal bevel-gear on the vertical shaft of
# the cylinder (10 cm across, 30 cm long) hanging below the table, so the cylinder turns once for each turn of the crank. The spur-gear
# also gears into an upright toothed rack in front of it; the rack slides in guides beside the cylinder and carries the marking point
# to the cylinder's face, raising it 22.0 cm for each turn: a spiral of that pitch. The one driven joint is the crank,
# 8 rev/min; the rack's own weight is lifted by the gearing. The point is drawn just touching the face and is not in contact.
# Generator: opencode-runs/batch12/gen368.py.
number: 368
slug: spiral-line-on-cylinder
name: Describing a spiral line on a cylinder
brown: "Describing spiral line on a cylinder. The spur-gear which drives the bevel-gears, and thus gives rotary motion to the cylinder, also gears into the toothed rack, and thereby causes the marking point to traverse from end to end of the cylinder."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 80, solver: PGS, multiccd: true, duration_s: 9, floor: false}
bodies:
  # the cross-shaft: crank, spur-gear and bevel-gear
  - id: shaft
    shape: part
    pos: [0, 0, 0]
    density: 7800
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, 1.6, 0], to: [0, 22.5, 0], radius: 0.6, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0, 21.5, 0], to: [0, 21.5, -6], radius: 0.5, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0, 21.5, -6], to: [0, 25.5, -6], radius: 0.6, collide: 0, color: "#a88a5c"}
      - {kind: rod, from: [0, 21.0, 0], to: [0, 22.0, 0], radius: 1.3, collide: 0, color: "#8f8a80"}
  # the cylinder on its upright shaft, with the horizontal bevel-gear
  - id: cylinder
    shape: part
    pos: [0, 0, 0]
    density: 600
    color: "#e6d6b0"
    pieces:
      - {kind: rod, from: [0, 0, -1.6], to: [0, 0, -40.5], radius: 0.6, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0, 0, -38.0], to: [0, 0, -8.0], radius: 5.0, collide: 0}
      - {kind: rod, from: [5.0200, 0.0000, -37.8], to: [5.0200, 0.0000, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
      - {kind: rod, from: [3.5497, 3.5497, -37.8], to: [3.5497, 3.5497, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
      - {kind: rod, from: [0.0000, 5.0200, -37.8], to: [0.0000, 5.0200, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
      - {kind: rod, from: [-3.5497, 3.5497, -37.8], to: [-3.5497, 3.5497, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
      - {kind: rod, from: [-5.0200, 0.0000, -37.8], to: [-5.0200, 0.0000, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
      - {kind: rod, from: [-3.5497, -3.5497, -37.8], to: [-3.5497, -3.5497, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
      - {kind: rod, from: [-0.0000, -5.0200, -37.8], to: [-0.0000, -5.0200, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
      - {kind: rod, from: [3.5497, -3.5497, -37.8], to: [3.5497, -3.5497, -8.2], radius: 0.12, collide: 0, color: "#a5906a"}
  # the upright rack and the marking point
  - id: rack
    shape: part
    pos: [4.4375, 12.0, -35.0]
    density: 7800
    friction: 0.1
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[3.9375, -37.0], [4.9375, -37.0], [4.9375, 3.0], [3.9375, 3.0]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -36.0497], [3.9375, -35.2014], [3.1500, -35.4881], [3.1500, -35.7631]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -34.9501], [3.9375, -34.1019], [3.1500, -34.3885], [3.1500, -34.6635]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -33.8506], [3.9375, -33.0023], [3.1500, -33.2889], [3.1500, -33.5639]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -32.7510], [3.9375, -31.9028], [3.1500, -32.1894], [3.1500, -32.4644]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -31.6514], [3.9375, -30.8032], [3.1500, -31.0898], [3.1500, -31.3648]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -30.5519], [3.9375, -29.7036], [3.1500, -29.9903], [3.1500, -30.2653]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -29.4523], [3.9375, -28.6041], [3.1500, -28.8907], [3.1500, -29.1657]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -28.3528], [3.9375, -27.5045], [3.1500, -27.7912], [3.1500, -28.0662]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -27.2532], [3.9375, -26.4050], [3.1500, -26.6916], [3.1500, -26.9666]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -26.1537], [3.9375, -25.3054], [3.1500, -25.5920], [3.1500, -25.8670]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -25.0541], [3.9375, -24.2059], [3.1500, -24.4925], [3.1500, -24.7675]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -23.9545], [3.9375, -23.1063], [3.1500, -23.3929], [3.1500, -23.6679]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -22.8550], [3.9375, -22.0067], [3.1500, -22.2934], [3.1500, -22.5684]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -21.7554], [3.9375, -20.9072], [3.1500, -21.1938], [3.1500, -21.4688]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -20.6559], [3.9375, -19.8076], [3.1500, -20.0942], [3.1500, -20.3692]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -19.5563], [3.9375, -18.7081], [3.1500, -18.9947], [3.1500, -19.2697]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -18.4568], [3.9375, -17.6085], [3.1500, -17.8951], [3.1500, -18.1701]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -17.3572], [3.9375, -16.5090], [3.1500, -16.7956], [3.1500, -17.0706]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -16.2576], [3.9375, -15.4094], [3.1500, -15.6960], [3.1500, -15.9710]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -15.1581], [3.9375, -14.3098], [3.1500, -14.5965], [3.1500, -14.8715]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -14.0585], [3.9375, -13.2103], [3.1500, -13.4969], [3.1500, -13.7719]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -12.9590], [3.9375, -12.1107], [3.1500, -12.3973], [3.1500, -12.6723]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -11.8594], [3.9375, -11.0112], [3.1500, -11.2978], [3.1500, -11.5728]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -10.7599], [3.9375, -9.9116], [3.1500, -10.1982], [3.1500, -10.4732]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -9.6603], [3.9375, -8.8120], [3.1500, -9.0987], [3.1500, -9.3737]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -8.5607], [3.9375, -7.7125], [3.1500, -7.9991], [3.1500, -8.2741]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -7.4612], [3.9375, -6.6129], [3.1500, -6.8996], [3.1500, -7.1746]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -6.3616], [3.9375, -5.5134], [3.1500, -5.8000], [3.1500, -6.0750]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -5.2621], [3.9375, -4.4138], [3.1500, -4.7004], [3.1500, -4.9754]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -4.1625], [3.9375, -3.3143], [3.1500, -3.6009], [3.1500, -3.8759]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -3.0630], [3.9375, -2.2147], [3.1500, -2.5013], [3.1500, -2.7763]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -1.9634], [3.9375, -1.1151], [3.1500, -1.4018], [3.1500, -1.6768]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, -0.8638], [3.9375, -0.0156], [3.1500, -0.3022], [3.1500, -0.5772]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, 0.2357], [3.9375, 1.0840], [3.1500, 0.7973], [3.1500, 0.5223]], y: [11.2, 12.8], collide: 1}
      - {kind: poly, points: [[3.9375, 1.3353], [3.9375, 2.1835], [3.1500, 1.8969], [3.1500, 1.6219]], y: [11.2, 12.8], collide: 1}
      - {kind: rod, from: [4.4375, 11.2, -35.0], to: [4.4375, 7.5, -35.0], radius: 0.4, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [4.4375, 7.5, -35.0], to: [0.9, 5.15, -35.0], radius: 0.3, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0.9, 5.15, -35.0], to: [0.5, 5.03, -35.0], radius: 0.1, collide: 0, color: "#3b342a"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-8, -6.2], [3.4375, -6.2], [3.4375, -5.2], [-8, -5.2]], y: [-10, 27], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[5.3375, -6.2], [8, -6.2], [8, -5.2], [5.3375, -5.2]], y: [-10, 27], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[-8, -42.0], [8, -42.0], [8, -41.0], [-8, -41.0]], y: [-10, 27], collide: 0, color: "#b9b09c"}
      - {kind: rod, from: [-7, -9, -41.0], to: [-7, -9, -6.2], radius: 0.8, collide: 0, color: "#a89f8b"}
      - {kind: rod, from: [-7, 26, -41.0], to: [-7, 26, -6.2], radius: 0.8, collide: 0, color: "#a89f8b"}
      - {kind: poly, points: [[-1.4, -5.2], [1.4, -5.2], [1.4, -1.0], [-1.4, -1.0]], y: [5.5, 7.5], collide: 0}
      - {kind: poly, points: [[-1.4, -5.2], [1.4, -5.2], [1.4, -1.0], [-1.4, -1.0]], y: [16.0, 18.0], collide: 0}
      - {kind: poly, points: [[-2.2, -41.0], [2.2, -41.0], [2.2, -39.5], [-2.2, -39.5]], y: [-2.2, 2.2], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[4.9875, -9], [6.1375, -9], [6.1375, -6.2], [4.9875, -6.2]], y: [10.4, 14.7], collide: 0}
      - {kind: poly, points: [[4.9875, -26], [6.1375, -26], [6.1375, -23], [4.9875, -23]], y: [10.4, 14.7], collide: 0}
      - {kind: poly, points: [[3.5375, -41.0], [6.1375, -41.0], [6.1375, -6.2], [3.5375, -6.2]], y: [13.7, 14.7], collide: 0}
joints:
  - {id: j_s, type: hinge, body: shaft, axis: [0, -1, 0], damping: 0.002}   # the one driven joint: the crank and cross-shaft
  - {id: j_c, type: hinge, body: cylinder, axis: [0, 0, 1], damping: 0.01}
  - {id: j_r, type: slide, body: rack, axis: [0, 0, 1], range: [-1, 28], damping: 0.05}   # + : up
spurs:
  - {id: sg, body: shaft, pos: [0, 12.0, 0], teeth: 20, module: 0.35, width: 1.6, backlash: 0.02, phase: 0.0, meets_parts: true}
bevels:
  - {id: b1, body: shaft, teeth: 20, pitch_radius: 4.0, cone_angle: 0.7854, face_width: 1.8, backlash: 0.04, phase: 0.0, quat: [1, 0, 0, 0]}
  - {id: b2, body: cylinder, teeth: 20, pitch_radius: 4.0, cone_angle: 0.7854, face_width: 1.8, backlash: 0.04, phase: 0.1571, quat: [0.7071068, -0.7071068, 0, 0]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_s, kind: velocity, rpm: 8, kv: 2, max_torque: 5}
checks:
  - {type: follow, out: j_r, in: j_s, expect: 0.0350, tol: 0.00105, min_r2: 0.995, settle_s: 1.0, window_s: 7}
  - {type: ratio, out: j_c, in: j_s, expect: -1.0, tol: 0.03, settle_s: 1.0, window_s: 7}
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [0, 8.0, -31.0], position: [165.0, 53.0, -18.0], fov: 30}
display:
  output: j_c
  labels: {j_s: "Crank, spur- and bevel-gear (driver)", j_c: "Cylinder", j_r: "Rack and marking point"}

