# No. 211 (Brown 1868): "A continuous rotary motion of the large wheel gives an intermittent rotary motion to the pinion-shaft. The part of the pinion shown next the wheel is
# cut of the same curve as the plain portion of the circumference of the wheel, and therefore serves as a lock while the wheel makes a part of a revolution, and until the pin upon the
# wheel strikes the guide-piece upon the pinion, when the pinion-shaft commences another revolution."
#
# Model (cm, module 0.8, No. 34's straight-flanked teeth): the pinion (16 tooth places) has teeth on 13; the other three and the spaces between them are filled and cut to an arc of
# radius 19.51 about the wheel's centre, a hair larger than the wheel's plain rim (19.45), so while that rim runs past, the pinion cannot turn either way. The large wheel (48 tooth places)
# has teeth on a segment of 14 and the plain rim elsewhere, cut back to its root where the pinion must turn. A pin on the wheel's face, in front, meets the guide-piece on the pinion's face
# as the segment comes round; the guide's curve is the envelope of the pin for a pinion speeding up smoothly from rest to the gearing's speed over 12 degrees of the wheel, when the
# segment's first tooth takes over. The segment turns the pinion on round to its lock, one turn for each turn of the wheel. Only the wheel is driven (10 rpm). Generator: opencode-runs/batch11/gen211.py.
number: 211
slug: locking-pinion-pin-guide-piece
name: Intermittent rotary motion with a locking pinion, pin and guide-piece
brown: "A continuous rotary motion of the large wheel gives an intermittent rotary motion to the pinion-shaft. The part of the pinion shown next the wheel is cut of the same curve as the plain portion of the circumference of the wheel, and therefore serves as a lock while the wheel makes a part of a revolution, and until the pin upon the wheel strikes the guide-piece upon the pinion, when the pinion-shaft commences another revolution."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 13.0
  floor: false
bodies:
  - id: pinion
    shape: part
    pos: [0, 0, 0]
    density: 2700
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 5.57, inner: 0.6, y: [-0.8, 0.8]}
      - {kind: disc, center: [0, 0], radius: 1.4, inner: 0.6, y: [-2.0, 1.2]}   # the boss
      - {kind: poly, points: [[4.5213, 3.3276], [3.3276, 4.5213], [4.6746, 5.1683], [5.1683, 4.6746]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[2.9037, 4.8045], [1.344, 5.4506], [2.341, 6.5638], [2.986, 6.2966]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[0.8441, 5.55], [-0.8441, 5.55], [-0.3491, 6.96], [0.3491, 6.96]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-1.344, 5.4506], [-2.9037, 4.8045], [-2.986, 6.2966], [-2.341, 6.5638]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-3.3276, 4.5213], [-4.5213, 3.3276], [-5.1683, 4.6746], [-4.6746, 5.1683]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-4.8045, 2.9037], [-5.4506, 1.344], [-6.5638, 2.341], [-6.2966, 2.986]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-5.55, 0.8441], [-5.55, -0.8441], [-6.96, -0.3491], [-6.96, 0.3491]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-5.4506, -1.344], [-4.8045, -2.9037], [-6.2966, -2.986], [-6.5638, -2.341]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-4.5213, -3.3276], [-3.3276, -4.5213], [-4.6746, -5.1683], [-5.1683, -4.6746]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-2.9037, -4.8045], [-1.344, -5.4506], [-2.341, -6.5638], [-2.986, -6.2966]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-0.8441, -5.55], [0.8441, -5.55], [0.3491, -6.96], [-0.3491, -6.96]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[1.344, -5.4506], [2.9037, -4.8045], [2.986, -6.2966], [2.341, -6.5638]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[3.3276, -4.5213], [4.5213, -3.3276], [5.1683, -4.6746], [4.6746, -5.1683]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.2966, -2.986], [4.8045, -2.9037], [5.1275, -2.1239], [6.295, -2.6075], [6.3356, -2.892]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.295, -2.6075], [5.1275, -2.1239], [5.2153, -1.8982], [6.2532, -2.276]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.2532, -2.276], [5.2153, -1.8982], [5.2931, -1.6689], [6.2188, -1.9608]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.2188, -1.9608], [5.2931, -1.6689], [5.3609, -1.4364], [6.1907, -1.6588]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.1907, -1.6588], [5.3609, -1.4364], [5.4184, -1.2012], [6.168, -1.3674]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.168, -1.3674], [5.4184, -1.2012], [5.4657, -0.9637], [6.1502, -1.0844]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.1502, -1.0844], [5.4657, -0.9637], [5.5025, -0.7244], [6.1368, -0.8079]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.1368, -0.8079], [5.5025, -0.7244], [5.5289, -0.4837], [6.1274, -0.5361]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.1274, -0.5361], [5.5289, -0.4837], [5.5447, -0.2421], [6.1219, -0.2673]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[6.1219, -0.2673], [5.5447, -0.2421], [5.55, 0.0], [6.12, 0.0]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.55, 0.0], [5.5447, 0.2421], [6.1219, 0.2673], [6.12, 0.0]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.5447, 0.2421], [5.5289, 0.4837], [6.1274, 0.5361], [6.1219, 0.2673]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.5289, 0.4837], [5.5025, 0.7244], [6.1368, 0.8079], [6.1274, 0.5361]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.5025, 0.7244], [5.4657, 0.9637], [6.1502, 1.0844], [6.1368, 0.8079]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.4657, 0.9637], [5.4184, 1.2012], [6.168, 1.3674], [6.1502, 1.0844]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.4184, 1.2012], [5.3609, 1.4364], [6.1907, 1.6588], [6.168, 1.3674]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.3609, 1.4364], [5.2931, 1.6689], [6.2188, 1.9608], [6.1907, 1.6588]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.2931, 1.6689], [5.2153, 1.8982], [6.2532, 2.276], [6.2188, 1.9608]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.2153, 1.8982], [5.1275, 2.1239], [6.295, 2.6075], [6.2532, 2.276]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.1275, 2.1239], [4.8045, 2.9037], [6.2966, 2.986], [6.3356, 2.892], [6.295, 2.6075]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[5.3569, -1.6489], [5.3397, -1.4214], [6.1377, -1.3641], [6.1543, -1.5841]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.377, -1.8788], [5.3569, -1.6489], [6.1543, -1.5841], [6.1735, -1.8049]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.3997, -2.11], [5.377, -1.8788], [6.1735, -1.8049], [6.1953, -2.0261]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.4308, -2.3663], [5.3997, -2.11], [6.1953, -2.0261], [6.223, -2.2542]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.474, -2.627], [5.4308, -2.3663], [6.223, -2.2542], [6.2597, -2.4763]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.5324, -2.8896], [5.474, -2.627], [6.2597, -2.4763], [6.3075, -2.6915]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.6105, -3.1547], [5.5324, -2.8896], [6.3075, -2.6915], [6.3687, -2.8996]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.7136, -3.4221], [5.6105, -3.1547], [6.3687, -2.8996], [6.4461, -3.1005]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[5.8478, -3.6895], [5.7136, -3.4221], [6.4461, -3.1005], [6.5426, -3.2929]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[6.0191, -3.952], [5.8478, -3.6895], [6.5426, -3.2929], [6.661, -3.4745]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[6.232, -4.2014], [6.0191, -3.952], [6.661, -3.4745], [6.8036, -3.6417]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[6.4869, -4.4264], [6.232, -4.2014], [6.8036, -3.6417], [6.9708, -3.7894]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[6.7793, -4.6154], [6.4869, -4.4264], [6.9708, -3.7894], [7.1612, -3.9124]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[7.0999, -4.7591], [6.7793, -4.6154], [7.1612, -3.9124], [7.371, -4.0064]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[7.4374, -4.8533], [7.0999, -4.7591], [7.371, -4.0064], [7.596, -4.0692]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[7.782, -4.8985], [7.4374, -4.8533], [7.596, -4.0692], [7.8321, -4.1001]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[7.782, -4.8985], [7.8321, -4.1001], [8.0766, -4.0997], [8.127, -4.8982]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[8.127, -4.8982], [8.0766, -4.0997], [8.328, -4.0691], [8.4692, -4.8565]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[8.4692, -4.8565], [8.328, -4.0691], [8.5858, -4.0086], [8.8079, -4.7772]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[8.8079, -4.7772], [8.5858, -4.0086], [8.8419, -3.9213], [9.1244, -4.6697]], y: [-2.0, -1.2], collide: 2}
      - {kind: poly, points: [[6.5503, -4.0693], [-0.46, -0.8879], [0.46, 0.8879], [7.1023, -3.0038]], y: [-1.9, -1.3], collide: 0}
      - {kind: disc, center: [-3.2221, 1.6057], radius: 2.4417, y: [-2.0, -1.2], collide: 0, color: "#b8ab8a"}   # the counterweight
  - id: wheel
    shape: part
    pos: [25.63, 0, 0]
    density: 2700
    friction: 0.1
    color: "#cbbd99"
    pieces:
      - {kind: disc, center: [25.63, 0], radius: 18.35, inner: 0.7, y: [-0.6, 0.6]}
      - {kind: disc, center: [25.63, 0], radius: 2.6, inner: 0.7, y: [-1.0, 1.0]}
      - {kind: poly, points: [[41.1025, 9.9013], [40.1282, 11.2799], [41.5654, 11.6895], [41.9683, 11.1193]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[39.6778, 11.8362], [38.5318, 13.0758], [39.9032, 13.6695], [40.3772, 13.1568]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[38.0127, 13.5685], [36.7147, 14.648], [37.9969, 15.4155], [38.5337, 14.9691]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[36.1357, 15.0687], [34.708, 15.9695], [35.879, 16.8979], [36.4695, 16.5253]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[34.079, 16.311], [32.5458, 17.0178], [33.5857, 18.0911], [34.2197, 17.7988]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[31.8777, 17.2743], [30.2654, 17.7749], [31.1563, 18.9747], [31.8231, 18.7677]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[29.5695, 17.942], [27.9057, 18.2279], [28.6323, 19.5337], [29.3204, 19.4155]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[27.1939, 18.3027], [25.507, 18.369], [26.0569, 19.7585], [26.7546, 19.7311]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[24.7915, 18.3503], [23.1104, 18.1958], [23.4743, 19.6452], [24.1696, 19.709]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[22.4035, 18.0838], [20.7569, 17.7112], [20.9285, 19.1957], [21.6095, 19.3498]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[20.0707, 17.508], [18.4868, 16.9237], [18.4632, 18.4178], [19.1182, 18.6595]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[17.833, 16.6325], [16.339, 15.8465], [16.1205, 17.3248], [16.7384, 17.6499]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[15.7287, 15.4725], [14.3501, 14.4982], [13.9405, 15.9354], [14.5107, 16.3383]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[13.7938, 14.0478], [12.5542, 12.9018], [11.9605, 14.2732], [12.4732, 14.7472]], y: [-0.8, 0.8], collide: 1}
      - {kind: band, center: [25.63, 0], r: [18.33, 19.45], a: [-3.7874, 0.4538], y: [-0.8, 0.8], slices: 121, collide: 1}
      - {kind: disc, center: [8.2726, 7.728], radius: 0.5, y: [-2.2, -0.6], collide: 1, color: "#6f6a60"}   # the pin
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, -2.6, 0], to: [0, 2.6, 0], radius: 0.6, color: "#8f8a80"}   # the pinion's shaft
      - {kind: rod, from: [25.63, -1.6, 0], to: [25.63, 2.6, 0], radius: 0.7, color: "#8f8a80"}   # the wheel's shaft
      - {kind: poly, points: [[-1.2, -19.5], [1.2, -19.5], [0.9, 0], [-0.9, 0]], y: [1.6, 2.6]}   # the standards, behind
      - {kind: poly, points: [[24.43, -19.5], [26.83, -19.5], [26.53, 0], [24.73, 0]], y: [1.6, 2.6]}
      - {kind: poly, points: [[-9, -20.5], [47.63, -20.5], [47.63, -19.5], [-9, -19.5]], y: [-3, 3], color: "#b9b09c"}
joints:
  - {id: j_wheel, type: hinge, body: wheel, axis: [0, -1, 0], damping: 0.01}   # the one driven joint; +: counter-clockwise
  - {id: j_pinion, type: hinge, body: pinion, axis: [0, -1, 0], damping: 0.002, frictionloss: 0.002}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_wheel, kind: velocity, rpm: 10, kv: 20, max_torque: 40}
checks:
  - {type: ratio, out: j_pinion, in: j_wheel, expect: -1.0, tol: 0.03, settle_s: 0.1, window_s: 12}
  - {type: ratio_range, out: j_pinion, in: j_wheel, min: -3.4, max: 0.15, min_swing: 2.5, settle_s: 0.1, window_s: 12, slices: 24}
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [15.815, 0, -2.5], position: [15.815, -128, -1.5], fov: 34}
display:
  output: j_pinion
  labels: {j_wheel: "Large wheel (driver)", j_pinion: "Pinion-shaft"}
  proof: {label: "Contact off", sub: "the wheel turns alone: the pinion stays put"}

