# No. 42, Different kinds of gears for transmitting rotary motion from one shaft to another arranged
# obliquely thereto (Brown 1868; plate 42-43).
#
# Model (cm): bevel-gears for shafts meeting at 60 deg (not a right angle): a 20-tooth gear on an
# upright shaft drives a 30-tooth gear on a shaft leaning 60 deg from it. Pitch cones with a common
# apex where the shaft lines meet: tan g1 = sin 60 / (30/20 + cos 60), so the half-angles are 23.41 deg
# and 36.59 deg (sum 60), and the cone distance is 10.07 for both (module 0.4: pitch radii 4 and 6).
# Only the upright shaft is motor-driven; the oblique shaft turns only through the teeth (20/30).
number: 42
slug: oblique-bevel-gears
name: Bevel-gears for oblique shafts
brown: "Different kinds of gears for transmitting rotary motion from one shaft to another arranged obliquely thereto."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  duration_s: 6
  solver: PGS
  multiccd: true
  floor: false
bodies:
  - {id: upright, shape: assembly, pos: [0, 0, 0], color: "#e2d8bf"}   # its gear's apex at the origin
  - {id: oblique, shape: assembly, pos: [0, 0, 0], color: "#d9cfb6"}   # leaning 60 deg; apex at the origin too
joints:
  - {id: j_up, type: hinge, body: upright, axis: [0, 0, 1], damping: 0.005}
  - {id: j_ob, type: hinge, body: oblique, axis: [-0.8660254, 0, 0.5000000], damping: 0.02}
bevels:
  - {id: g20, body: upright, teeth: 20, pitch_radius: 4, cone_angle: 0.4086379, face_width: 2.5, backlash: 0.04, phase: 0, quat: [0.7071068, 0.7071068, 0, 0]}
  - {id: g30, body: oblique, teeth: 30, pitch_radius: 6, cone_angle: 0.6385597, face_width: 2.5, backlash: 0.04, phase: 0.105, quat: [0.6123724, 0.6123724, -0.3535534, 0.3535534]}
shafts:
  - {id: sh_up, body: upright, from: [0, 0, 8.4], to: [0, 0, 16], radius: 0.5}
  - {id: sh_up_collar, body: upright, from: [0, 0, 9.2], to: [0, 0, 10.6], radius: 0.9}
  - {id: sh_ob, body: oblique, from: [-6.4086, 0, 3.7], to: [-13.8564, 0, 8.0], radius: 0.5}
  - {id: sh_ob_collar, body: oblique, from: [-6.9282, 0, 4.0], to: [-8.1406, 0, 4.7], radius: 1.0}
contact: {solref: [0.0008, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_up, kind: velocity, rpm: 30, kv: 2, max_torque: 5}
checks:
  # 20/30; negative because both joint axes point away from the common apex
  - {type: ratio, out: j_ob, in: j_up, expect: -0.66667, tol: 0.005, settle_s: 1, window_s: 5}
  - {type: penetration, max: 0.0008, settle_s: 2}
camera: {target: [-3, 0, 7], position: [-1, -60, 20], fov: 30}
display:
  output: j_ob
  labels: {j_up: "Upright shaft (driver, 20 teeth)", j_ob: "Oblique shaft (30 teeth), driven only by the teeth"}
  expect: {default: -0.6667}
  proof: {label: "Teeth out of contact", sub: "the gears stop touching: the oblique shaft stops"}
