# No. 234 (Brown 1868): "Represents a verge escapement. On oscillating the spindle, S, the crown-wheel has an intermittent rotary motion."
#
# Model (cm, gravity on): a crown-wheel of 15 sawtooth teeth (an odd number, so that a tooth stands at one end of a diameter when a space is at the
# other) on an upright axle, turned by a constant torque (a clock's weight; the one driven joint). Above it the spindle S lies across the wheel 3.7 above
# the rim; on it two pallets A, 3 long, over the teeth at the two ends of the diameter, leaning 40 degrees either side of straight down, and
# at one end a foliot (a balanced bar with two weights) that gives the spindle its inertia. A tooth pushes one pallet aside and the spindle swings; the
# other pallet swings down in front of a tooth on the far side, which stops the wheel, drives the spindle back (the verge's recoil) and escapes in turn.
# The spindle oscillates, and the wheel goes round intermittently, half a tooth a beat. Generator: opencode-runs/batch11/gen234.py.
number: 234
slug: verge-escapement
name: A verge escapement
brown: "Represents a verge escapement. On oscillating the spindle, S, the crown-wheel has an intermittent rotary motion."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: false
  duration_s: 10.0
  floor: false
bodies:
  - id: crown
    shape: part
    pos: [0, 0, 0]
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: loft, a: [[7.3, 0.0, -0.6], [8.7, 0.0, -0.6], [8.5099, 1.8088, -0.6], [7.1405, 1.5178, -0.6]], b: [[7.3, 0.0, 0.0], [8.7, 0.0, 0.0], [8.5099, 1.8088, 0.0], [7.1405, 1.5178, 0.0]]}
      - {kind: loft, a: [[7.1405, 1.5178, -0.6], [8.5099, 1.8088, -0.6], [7.9478, 3.5386, -0.6], [6.6689, 2.9692, -0.6]], b: [[7.1405, 1.5178, 0.0], [8.5099, 1.8088, 0.0], [7.9478, 3.5386, 0.0], [6.6689, 2.9692, 0.0]]}
      - {kind: loft, a: [[6.6689, 2.9692, -0.6], [7.9478, 3.5386, -0.6], [7.0384, 5.1137, -0.6], [5.9058, 4.2908, -0.6]], b: [[6.6689, 2.9692, 0.0], [7.9478, 3.5386, 0.0], [7.0384, 5.1137, 0.0], [5.9058, 4.2908, 0.0]]}
      - {kind: loft, a: [[5.9058, 4.2908, -0.6], [7.0384, 5.1137, -0.6], [5.8214, 6.4654, -0.6], [4.8847, 5.425, -0.6]], b: [[5.9058, 4.2908, 0.0], [7.0384, 5.1137, 0.0], [5.8214, 6.4654, 0.0], [4.8847, 5.425, 0.0]]}
      - {kind: loft, a: [[4.8847, 5.425, -0.6], [5.8214, 6.4654, -0.6], [4.35, 7.5344, -0.6], [3.65, 6.322, -0.6]], b: [[4.8847, 5.425, 0.0], [5.8214, 6.4654, 0.0], [4.35, 7.5344, 0.0], [3.65, 6.322, 0.0]]}
      - {kind: loft, a: [[3.65, 6.322, -0.6], [4.35, 7.5344, -0.6], [2.6884, 8.2742, -0.6], [2.2558, 6.9427, -0.6]], b: [[3.65, 6.322, 0.0], [4.35, 7.5344, 0.0], [2.6884, 8.2742, 0.0], [2.2558, 6.9427, 0.0]]}
      - {kind: loft, a: [[2.2558, 6.9427, -0.6], [2.6884, 8.2742, -0.6], [0.9094, 8.6523, -0.6], [0.7631, 7.26, -0.6]], b: [[2.2558, 6.9427, 0.0], [2.6884, 8.2742, 0.0], [0.9094, 8.6523, 0.0], [0.7631, 7.26, 0.0]]}
      - {kind: loft, a: [[0.7631, 7.26, -0.6], [0.9094, 8.6523, -0.6], [-0.9094, 8.6523, -0.6], [-0.7631, 7.26, -0.6]], b: [[0.7631, 7.26, 0.0], [0.9094, 8.6523, 0.0], [-0.9094, 8.6523, 0.0], [-0.7631, 7.26, 0.0]]}
      - {kind: loft, a: [[-0.7631, 7.26, -0.6], [-0.9094, 8.6523, -0.6], [-2.6884, 8.2742, -0.6], [-2.2558, 6.9427, -0.6]], b: [[-0.7631, 7.26, 0.0], [-0.9094, 8.6523, 0.0], [-2.6884, 8.2742, 0.0], [-2.2558, 6.9427, 0.0]]}
      - {kind: loft, a: [[-2.2558, 6.9427, -0.6], [-2.6884, 8.2742, -0.6], [-4.35, 7.5344, -0.6], [-3.65, 6.322, -0.6]], b: [[-2.2558, 6.9427, 0.0], [-2.6884, 8.2742, 0.0], [-4.35, 7.5344, 0.0], [-3.65, 6.322, 0.0]]}
      - {kind: loft, a: [[-3.65, 6.322, -0.6], [-4.35, 7.5344, -0.6], [-5.8214, 6.4654, -0.6], [-4.8847, 5.425, -0.6]], b: [[-3.65, 6.322, 0.0], [-4.35, 7.5344, 0.0], [-5.8214, 6.4654, 0.0], [-4.8847, 5.425, 0.0]]}
      - {kind: loft, a: [[-4.8847, 5.425, -0.6], [-5.8214, 6.4654, -0.6], [-7.0384, 5.1137, -0.6], [-5.9058, 4.2908, -0.6]], b: [[-4.8847, 5.425, 0.0], [-5.8214, 6.4654, 0.0], [-7.0384, 5.1137, 0.0], [-5.9058, 4.2908, 0.0]]}
      - {kind: loft, a: [[-5.9058, 4.2908, -0.6], [-7.0384, 5.1137, -0.6], [-7.9478, 3.5386, -0.6], [-6.6689, 2.9692, -0.6]], b: [[-5.9058, 4.2908, 0.0], [-7.0384, 5.1137, 0.0], [-7.9478, 3.5386, 0.0], [-6.6689, 2.9692, 0.0]]}
      - {kind: loft, a: [[-6.6689, 2.9692, -0.6], [-7.9478, 3.5386, -0.6], [-8.5099, 1.8088, -0.6], [-7.1405, 1.5178, -0.6]], b: [[-6.6689, 2.9692, 0.0], [-7.9478, 3.5386, 0.0], [-8.5099, 1.8088, 0.0], [-7.1405, 1.5178, 0.0]]}
      - {kind: loft, a: [[-7.1405, 1.5178, -0.6], [-8.5099, 1.8088, -0.6], [-8.7, 0.0, -0.6], [-7.3, 0.0, -0.6]], b: [[-7.1405, 1.5178, 0.0], [-8.5099, 1.8088, 0.0], [-8.7, 0.0, 0.0], [-7.3, 0.0, 0.0]]}
      - {kind: loft, a: [[-7.3, 0.0, -0.6], [-8.7, 0.0, -0.6], [-8.5099, -1.8088, -0.6], [-7.1405, -1.5178, -0.6]], b: [[-7.3, 0.0, 0.0], [-8.7, 0.0, 0.0], [-8.5099, -1.8088, 0.0], [-7.1405, -1.5178, 0.0]]}
      - {kind: loft, a: [[-7.1405, -1.5178, -0.6], [-8.5099, -1.8088, -0.6], [-7.9478, -3.5386, -0.6], [-6.6689, -2.9692, -0.6]], b: [[-7.1405, -1.5178, 0.0], [-8.5099, -1.8088, 0.0], [-7.9478, -3.5386, 0.0], [-6.6689, -2.9692, 0.0]]}
      - {kind: loft, a: [[-6.6689, -2.9692, -0.6], [-7.9478, -3.5386, -0.6], [-7.0384, -5.1137, -0.6], [-5.9058, -4.2908, -0.6]], b: [[-6.6689, -2.9692, 0.0], [-7.9478, -3.5386, 0.0], [-7.0384, -5.1137, 0.0], [-5.9058, -4.2908, 0.0]]}
      - {kind: loft, a: [[-5.9058, -4.2908, -0.6], [-7.0384, -5.1137, -0.6], [-5.8214, -6.4654, -0.6], [-4.8847, -5.425, -0.6]], b: [[-5.9058, -4.2908, 0.0], [-7.0384, -5.1137, 0.0], [-5.8214, -6.4654, 0.0], [-4.8847, -5.425, 0.0]]}
      - {kind: loft, a: [[-4.8847, -5.425, -0.6], [-5.8214, -6.4654, -0.6], [-4.35, -7.5344, -0.6], [-3.65, -6.322, -0.6]], b: [[-4.8847, -5.425, 0.0], [-5.8214, -6.4654, 0.0], [-4.35, -7.5344, 0.0], [-3.65, -6.322, 0.0]]}
      - {kind: loft, a: [[-3.65, -6.322, -0.6], [-4.35, -7.5344, -0.6], [-2.6884, -8.2742, -0.6], [-2.2558, -6.9427, -0.6]], b: [[-3.65, -6.322, 0.0], [-4.35, -7.5344, 0.0], [-2.6884, -8.2742, 0.0], [-2.2558, -6.9427, 0.0]]}
      - {kind: loft, a: [[-2.2558, -6.9427, -0.6], [-2.6884, -8.2742, -0.6], [-0.9094, -8.6523, -0.6], [-0.7631, -7.26, -0.6]], b: [[-2.2558, -6.9427, 0.0], [-2.6884, -8.2742, 0.0], [-0.9094, -8.6523, 0.0], [-0.7631, -7.26, 0.0]]}
      - {kind: loft, a: [[-0.7631, -7.26, -0.6], [-0.9094, -8.6523, -0.6], [0.9094, -8.6523, -0.6], [0.7631, -7.26, -0.6]], b: [[-0.7631, -7.26, 0.0], [-0.9094, -8.6523, 0.0], [0.9094, -8.6523, 0.0], [0.7631, -7.26, 0.0]]}
      - {kind: loft, a: [[0.7631, -7.26, -0.6], [0.9094, -8.6523, -0.6], [2.6884, -8.2742, -0.6], [2.2558, -6.9427, -0.6]], b: [[0.7631, -7.26, 0.0], [0.9094, -8.6523, 0.0], [2.6884, -8.2742, 0.0], [2.2558, -6.9427, 0.0]]}
      - {kind: loft, a: [[2.2558, -6.9427, -0.6], [2.6884, -8.2742, -0.6], [4.35, -7.5344, -0.6], [3.65, -6.322, -0.6]], b: [[2.2558, -6.9427, 0.0], [2.6884, -8.2742, 0.0], [4.35, -7.5344, 0.0], [3.65, -6.322, 0.0]]}
      - {kind: loft, a: [[3.65, -6.322, -0.6], [4.35, -7.5344, -0.6], [5.8214, -6.4654, -0.6], [4.8847, -5.425, -0.6]], b: [[3.65, -6.322, 0.0], [4.35, -7.5344, 0.0], [5.8214, -6.4654, 0.0], [4.8847, -5.425, 0.0]]}
      - {kind: loft, a: [[4.8847, -5.425, -0.6], [5.8214, -6.4654, -0.6], [7.0384, -5.1137, -0.6], [5.9058, -4.2908, -0.6]], b: [[4.8847, -5.425, 0.0], [5.8214, -6.4654, 0.0], [7.0384, -5.1137, 0.0], [5.9058, -4.2908, 0.0]]}
      - {kind: loft, a: [[5.9058, -4.2908, -0.6], [7.0384, -5.1137, -0.6], [7.9478, -3.5386, -0.6], [6.6689, -2.9692, -0.6]], b: [[5.9058, -4.2908, 0.0], [7.0384, -5.1137, 0.0], [7.9478, -3.5386, 0.0], [6.6689, -2.9692, 0.0]]}
      - {kind: loft, a: [[6.6689, -2.9692, -0.6], [7.9478, -3.5386, -0.6], [8.5099, -1.8088, -0.6], [7.1405, -1.5178, -0.6]], b: [[6.6689, -2.9692, 0.0], [7.9478, -3.5386, 0.0], [8.5099, -1.8088, 0.0], [7.1405, -1.5178, 0.0]]}
      - {kind: loft, a: [[7.1405, -1.5178, -0.6], [8.5099, -1.8088, -0.6], [8.7, -0.0, -0.6], [7.3, -0.0, -0.6]], b: [[7.1405, -1.5178, 0.0], [8.5099, -1.8088, 0.0], [8.7, -0.0, 0.0], [7.3, -0.0, 0.0]]}
      - {kind: loft, a: [[0.0, 0.0, -0.9], [1.4, 0.0, -0.9], [0.9899, 0.9899, -0.9], [0.0, 0.0, -0.9]], b: [[0.0, 0.0, 0.2], [1.4, 0.0, 0.2], [0.9899, 0.9899, 0.2], [0.0, 0.0, 0.2]]}
      - {kind: loft, a: [[0.0, 0.0, -0.9], [0.9899, 0.9899, -0.9], [0.0, 1.4, -0.9], [0.0, 0.0, -0.9]], b: [[0.0, 0.0, 0.2], [0.9899, 0.9899, 0.2], [0.0, 1.4, 0.2], [0.0, 0.0, 0.2]]}
      - {kind: loft, a: [[0.0, 0.0, -0.9], [0.0, 1.4, -0.9], [-0.9899, 0.9899, -0.9], [-0.0, 0.0, -0.9]], b: [[0.0, 0.0, 0.2], [0.0, 1.4, 0.2], [-0.9899, 0.9899, 0.2], [-0.0, 0.0, 0.2]]}
      - {kind: loft, a: [[-0.0, 0.0, -0.9], [-0.9899, 0.9899, -0.9], [-1.4, 0.0, -0.9], [-0.0, 0.0, -0.9]], b: [[-0.0, 0.0, 0.2], [-0.9899, 0.9899, 0.2], [-1.4, 0.0, 0.2], [-0.0, 0.0, 0.2]]}
      - {kind: loft, a: [[-0.0, 0.0, -0.9], [-1.4, 0.0, -0.9], [-0.9899, -0.9899, -0.9], [-0.0, -0.0, -0.9]], b: [[-0.0, 0.0, 0.2], [-1.4, 0.0, 0.2], [-0.9899, -0.9899, 0.2], [-0.0, -0.0, 0.2]]}
      - {kind: loft, a: [[-0.0, -0.0, -0.9], [-0.9899, -0.9899, -0.9], [-0.0, -1.4, -0.9], [-0.0, -0.0, -0.9]], b: [[-0.0, -0.0, 0.2], [-0.9899, -0.9899, 0.2], [-0.0, -1.4, 0.2], [-0.0, -0.0, 0.2]]}
      - {kind: loft, a: [[-0.0, -0.0, -0.9], [-0.0, -1.4, -0.9], [0.9899, -0.9899, -0.9], [0.0, -0.0, -0.9]], b: [[-0.0, -0.0, 0.2], [-0.0, -1.4, 0.2], [0.9899, -0.9899, 0.2], [0.0, -0.0, 0.2]]}
      - {kind: loft, a: [[0.0, -0.0, -0.9], [0.9899, -0.9899, -0.9], [1.4, -0.0, -0.9], [0.0, -0.0, -0.9]], b: [[0.0, -0.0, 0.2], [0.9899, -0.9899, 0.2], [1.4, -0.0, 0.2], [0.0, -0.0, 0.2]]}
      - {kind: rod, from: [1.1464, 0.3546, -0.3], to: [7.0695, 2.1868, -0.3], radius: 0.28}
      - {kind: rod, from: [-0.3546, 1.1464, -0.3], to: [-2.1868, 7.0695, -0.3], radius: 0.28}
      - {kind: rod, from: [-1.1464, -0.3546, -0.3], to: [-7.0695, -2.1868, -0.3], radius: 0.28}
      - {kind: rod, from: [0.3546, -1.1464, -0.3], to: [2.1868, -7.0695, -0.3], radius: 0.28}
      - {kind: rod, from: [0, 0, -7.0], to: [0, 0, 0.6], radius: 0.4, color: "#8f8a80"}   # the axle
      - {kind: loft, a: [[7.0828, -2.4665, 0.0], [7.5, 0.0, 0.0], [7.5, 0.0, 1.6]], b: [[8.0272, -2.7954, 0.0], [8.5, 0.0, 0.0], [8.5, 0.0, 1.6]], collide: 1}
      - {kind: loft, a: [[7.4737, 0.6276, 0.0], [6.8516, 3.0505, 0.0], [6.8516, 3.0505, 1.6]], b: [[8.4702, 0.7113, 0.0], [7.7651, 3.4573, 0.0], [7.7651, 3.4573, 1.6]], collide: 1}
      - {kind: loft, a: [[6.5723, 3.6132, 0.0], [5.0185, 5.5736, 0.0], [5.0185, 5.5736, 1.6]], b: [[7.4486, 4.0949, 0.0], [5.6876, 6.3167, 0.0], [5.6876, 6.3167, 1.6]], collide: 1}
      - {kind: loft, a: [[4.5345, 5.974, 0.0], [2.3176, 7.1329, 0.0], [2.3176, 7.1329, 1.6]], b: [[5.1391, 6.7705, 0.0], [2.6266, 8.084, 0.0], [2.6266, 8.084, 1.6]], collide: 1}
      - {kind: loft, a: [[1.7126, 7.3018, 0.0], [-0.784, 7.4589, 0.0], [-0.784, 7.4589, 1.6]], b: [[1.941, 8.2754, 0.0], [-0.8885, 8.4534, 0.0], [-0.8885, 8.4534, 1.6]], collide: 1}
      - {kind: loft, a: [[-1.4054, 7.3672, 0.0], [-3.75, 6.4952, 0.0], [-3.75, 6.4952, 1.6]], b: [[-1.5927, 8.3494, 0.0], [-4.25, 7.3612, 0.0], [-4.25, 7.3612, 1.6]], collide: 1}
      - {kind: loft, a: [[-4.2804, 6.1586, 0.0], [-6.0676, 4.4084, 0.0], [-6.0676, 4.4084, 1.6]], b: [[-4.8511, 6.9798, 0.0], [-6.8766, 4.9962, 0.0], [-6.8766, 4.9962, 1.6]], collide: 1}
      - {kind: loft, a: [[-6.4152, 3.8852, 0.0], [-7.3361, 1.5593, 0.0], [-7.3361, 1.5593, 1.6]], b: [[-7.2706, 4.4032, 0.0], [-8.3143, 1.7672, 0.0], [-8.3143, 1.7672, 1.6]], collide: 1}
      - {kind: loft, a: [[-7.4409, 0.94, 0.0], [-7.3361, -1.5593, 0.0], [-7.3361, -1.5593, 1.6]], b: [[-8.433, 1.0653, 0.0], [-8.3143, -1.7672, 0.0], [-8.3143, -1.7672, 1.6]], collide: 1}
      - {kind: loft, a: [[-7.1799, -2.1677, 0.0], [-6.0676, -4.4084, 0.0], [-6.0676, -4.4084, 1.6]], b: [[-8.1372, -2.4568, 0.0], [-6.8766, -4.9962, 0.0], [-6.8766, -4.9962, 1.6]], collide: 1}
      - {kind: loft, a: [[-5.6775, -4.9007, 0.0], [-3.75, -6.4952, 0.0], [-3.75, -6.4952, 1.6]], b: [[-6.4345, -5.5541, 0.0], [-4.25, -7.3612, 0.0], [-4.25, -7.3612, 1.6]], collide: 1}
      - {kind: loft, a: [[-3.1933, -6.7862, 0.0], [-0.784, -7.4589, 0.0], [-0.784, -7.4589, 1.6]], b: [[-3.6191, -7.691, 0.0], [-0.8885, -8.4534, 0.0], [-0.8885, -8.4534, 1.6]], collide: 1}
      - {kind: loft, a: [[-0.1571, -7.4984, 0.0], [2.3176, -7.1329, 0.0], [2.3176, -7.1329, 1.6]], b: [[-0.178, -8.4981, 0.0], [2.6266, -8.084, 0.0], [2.6266, -8.084, 1.6]], collide: 1}
      - {kind: loft, a: [[2.9064, -6.914, 0.0], [5.0185, -5.5736, 0.0], [5.0185, -5.5736, 1.6]], b: [[3.2939, -7.8358, 0.0], [5.6876, -6.3167, 0.0], [5.6876, -6.3167, 1.6]], collide: 1}
      - {kind: loft, a: [[5.4673, -5.1341, 0.0], [6.8516, -3.0505, 0.0], [6.8516, -3.0505, 1.6]], b: [[6.1962, -5.8187, 0.0], [7.7651, -3.4573, 0.0], [7.7651, -3.4573, 1.6]], collide: 1}
  - id: verge
    shape: part
    pos: [0, 0, 3.7]
    friction: 0.1
    color: "#6b5a44"
    pieces:
      - {kind: rod, from: [-13.0, 0, 3.7], to: [11.0, 0, 3.7], radius: 0.22, color: "#8f8a80"}   # the spindle S
      - {kind: loft, a: [[7.25, 0.0779, 3.3738], [7.25, 1.8135, 1.3054], [7.25, 2.0433, 1.4983], [7.25, 0.3077, 3.5666]], b: [[8.75, 0.0779, 3.3738], [8.75, 1.8135, 1.3054], [8.75, 2.0433, 1.4983], [8.75, 0.3077, 3.5666]], collide: 2}   # A, at x = +8
      - {kind: loft, a: [[-8.75, -0.3077, 3.5666], [-8.75, -2.0433, 1.4983], [-8.75, -1.8135, 1.3054], [-8.75, -0.0779, 3.3738]], b: [[-7.25, -0.3077, 3.5666], [-7.25, -2.0433, 1.4983], [-7.25, -1.8135, 1.3054], [-7.25, -0.0779, 3.3738]], collide: 2}   # A, at x = -8
      - {kind: rod, from: [-12.0, -6.0, 3.7], to: [-12.0, 6.0, 3.7], radius: 0.25}   # the foliot
      - {kind: rod, from: [-12.6, -5.4, 3.7], to: [-11.4, -5.4, 3.7], radius: 0.9, color: "#8f8a80"}   # its weights
      - {kind: rod, from: [-12.6, 5.4, 3.7], to: [-11.4, 5.4, 3.7], radius: 0.9, color: "#8f8a80"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[9.6, -7.0], [10.8, -7.0], [10.6, 4.3], [9.8, 4.3]], y: [-0.6, 0.6]}   # the spindle's two cocks
      - {kind: poly, points: [[-10.8, -7.0], [-9.6, -7.0], [-9.8, 4.3], [-10.6, 4.3]], y: [-0.6, 0.6]}
      - {kind: poly, points: [[-1.5, -7.6], [1.5, -7.6], [1.5, -7.0], [-1.5, -7.0]], y: [-1.5, 1.5]}   # the axle's foot
      - {kind: poly, points: [[-15.0, -8.2], [12.0, -8.2], [12.0, -7.6], [-15.0, -7.6]], y: [-9, 9], color: "#b9b09c"}
joints:
  - {id: j_crown, type: hinge, body: crown, axis: [0, 0, 1], damping: 0.0005}   # the one driven joint; +: counter-clockwise seen from above
  - {id: j_verge, type: hinge, body: verge, axis: [1, 0, 0], damping: 0.0005}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
# The clock's weight: a constant torque on the crown-wheel. Nothing else is driven.
driver: {joint: j_crown, kind: torque, torque: 0.01, max_torque: 0.05}
checks:
  - {type: advance, joint: j_crown, beat: j_verge, expect: 0.20944, tol: 0.05, settle_s: 2, window_s: 7.5}   # half a tooth (2 pi / 15 / 2) a beat
  - {type: amplitude, joint: j_verge, min: 0.2, max: 1.2, sustain: 0.85, settle_s: 2, window_s: 7.5}
  - {type: penetration, max: 0.001, settle_s: 1}
camera: {target: [-1.5, 0, -1.5], position: [26.0, -48.0, 26.0], fov: 34}
display:
  output: j_verge
  swing: j_verge
  labels: {j_crown: "Crown-wheel (weight)", j_verge: "Spindle S and pallets"}
  proof: {label: "Pallets out of contact", sub: "nothing swings the spindle, and the weight spins the wheel freely"}

