# No. 378 (Brown 1868): "Saw for cutting trees by motion of pendulum, is represented as cutting a lying tree."
#
# Reading of the figure (cm, gravity on; Brown's front elevation): a bow-saw lies across the tree, its blade's edge on the
# wood. It slides to and fro in a light carriage, and the carriage hangs from two cords over pulleys at the tops of the frame's
# posts, with a counterweight on each, a little lighter than carriage and saw together, so the saw bears on the cut with only
# a small part of its weight and follows it down. A pendulum hung from the shear-legs on the left is swung to and fro (the one
# driven joint, the sawyer's hand) and pushes and pulls the saw through a link pinned to both.
# The shear-legs, the frame, the pulleys (fixed rounds for the cords) and the tree's rings are drawn only.
# Generator: opencode-runs/batch12/gen378.py.
number: 378
slug: pendulum-saw
name: Pendulum saw
brown: "Saw for cutting trees by motion of pendulum, is represented as cutting a lying tree."
units: cm
sim:
  timestep: 0.0005
  integrator: implicitfast
  iterations: 60
  solver: PGS
  duration_s: 10
  floor: false
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#b5a98f"
    pieces:
      - {kind: poly, points: [[-16.0, 0.0], [-14.0, 0.0], [-14.0, 24.0], [-16.0, 24.0]], y: [-1.0, 1.0], collide: 0}   # the frame's posts
      - {kind: poly, points: [[14.0, 0.0], [16.0, 0.0], [16.0, 24.0], [14.0, 24.0]], y: [-1.0, 1.0], collide: 0}
      - {kind: poly, points: [[-17.5, 24.0], [17.5, 24.0], [17.5, 26.5], [-17.5, 26.5]], y: [-1.2, 1.2], collide: 0}   # its head
      - {kind: poly, points: [[-20.0, -1.0], [-10.0, -1.0], [-10.0, 0.0], [-20.0, 0.0]], y: [-3.0, 3.0], collide: 0}   # its sills
      - {kind: poly, points: [[10.0, -1.0], [20.0, -1.0], [20.0, 0.0], [10.0, 0.0]], y: [-3.0, 3.0], collide: 0}
      - {kind: rod, from: [-19.0, 1.1, 0.0], to: [-15.0, 1.1, 5.0], radius: 0.4, collide: 0}   # its braces
      - {kind: rod, from: [-11.0, 1.1, 0.0], to: [-15.0, 1.1, 5.0], radius: 0.4, collide: 0}
      - {kind: rod, from: [19.0, 1.1, 0.0], to: [15.0, 1.1, 5.0], radius: 0.4, collide: 0}
      - {kind: rod, from: [11.0, 1.1, 0.0], to: [15.0, 1.1, 5.0], radius: 0.4, collide: 0}
      - {kind: disc, center: [-15.0, 22.0], radius: 2.0, y: [-1.6, -1.1], collide: 0, color: "#8f8a80"}   # the cords' pulleys
      - {kind: disc, center: [15.0, 22.0], radius: 2.0, y: [-1.6, -1.1], collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [-23.0, -3.0, 33.5], to: [-23.0, 3.0, 33.5], radius: 0.5, collide: 0, color: "#8f8a80"}   # the pendulum's pivot
      - {kind: rod, from: [-23.0, -1.5, 33.5], to: [-31.0, -1.5, 0.0], radius: 0.45, collide: 0}   # the shear-legs
      - {kind: rod, from: [-23.0, 1.5, 33.5], to: [-17.5, 1.5, 0.0], radius: 0.45, collide: 0}
      - {kind: rod, from: [-23.0, 0.0, 33.5], to: [-24.0, 9.0, 0.0], radius: 0.45, collide: 0}
      - {kind: disc, center: [-23.0, 33.5], radius: 1.4, inner: 0.6, y: [-2.2, -1.9], collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [-40.0, 0, -0.6], to: [30.0, 0, -0.6], radius: 0.05, collide: 0, color: "#c9bfa9"}   # the ground
      - {kind: disc, center: [0.0, 3.8], radius: 3.5, y: [-5.0, 5.0], collide: 2, color: "#b39a74"}   # the lying tree
      - {kind: disc, center: [0.0, 3.8], radius: 0.8, inner: 0.68, y: [-5.06, -5.02], collide: 0, color: "#6f5a3e"}
      - {kind: disc, center: [0.0, 3.8], radius: 1.6, inner: 1.48, y: [-5.06, -5.02], collide: 0, color: "#6f5a3e"}
      - {kind: disc, center: [0.0, 3.8], radius: 2.4, inner: 2.28, y: [-5.06, -5.02], collide: 0, color: "#6f5a3e"}
      - {kind: disc, center: [0.0, 3.8], radius: 3.1, inner: 2.98, y: [-5.06, -5.02], collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [3.1362, -5.04, 4.4357], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [2.1636, -5.04, 6.1577], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [0.3645, -5.04, 6.9792], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [-1.5738, -5.04, 6.5863], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [-2.9109, -5.04, 5.1291], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [-3.1362, -5.04, 3.1643], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [-2.1636, -5.04, 1.4423], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [-0.3645, -5.04, 0.6208], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [1.5738, -5.04, 1.0137], radius: 0.05, collide: 0, color: "#6f5a3e"}
      - {kind: rod, from: [0.0, -5.04, 3.8], to: [2.9109, -5.04, 2.4709], radius: 0.05, collide: 0, color: "#6f5a3e"}
  - id: carriage
    shape: part
    pos: [0, 0, 18.0]
    mass: 1
    color: "#9c8f76"
    pieces:
      - {kind: poly, points: [[-13.5, 17.2], [13.5, 17.2], [13.5, 18.6], [-13.5, 18.6]], y: [-0.6, 0.6], collide: 0}   # the saw's carriage, hung from the cords
      - {kind: poly, points: [[-13.4, 9.0], [-12.6, 9.0], [-12.6, 17.2], [-13.4, 17.2]], y: [-0.5, 0.5], collide: 0}
      - {kind: poly, points: [[12.6, 9.0], [13.4, 9.0], [13.4, 17.2], [12.6, 17.2]], y: [-0.5, 0.5], collide: 0}
      - {kind: poly, points: [[-12.4, 15.6], [12.4, 15.6], [12.4, 16.2], [-12.4, 16.2]], y: [0.7, 1.0], collide: 0}   # its guide, behind the saw
  - id: saw
    shape: part
    mount: carriage
    pos: [0, 0, 7.3]
    mass: 1
    friction: 0.5
    color: "#8a7f6e"
    pieces:
      - {kind: poly, points: [[-7.0, 7.3], [7.0, 7.3], [7.0, 9.1], [-7.0, 9.1]], y: [-0.08, 0.08], collide: 1, color: "#9aa0a6"}   # the blade (its edge on the wood)
      - {kind: poly, points: [[-7.0, 7.3], [-6.3, 7.3], [-6.65, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-6.3, 7.3], [-5.6, 7.3], [-5.95, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-5.6, 7.3], [-4.9, 7.3], [-5.25, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-4.9, 7.3], [-4.2, 7.3], [-4.55, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-4.2, 7.3], [-3.5, 7.3], [-3.85, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-3.5, 7.3], [-2.8, 7.3], [-3.15, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-2.8, 7.3], [-2.1, 7.3], [-2.45, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-2.1, 7.3], [-1.4, 7.3], [-1.75, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-1.4, 7.3], [-0.7, 7.3], [-1.05, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[-0.7, 7.3], [-0.0, 7.3], [-0.35, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[0.0, 7.3], [0.7, 7.3], [0.35, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[0.7, 7.3], [1.4, 7.3], [1.05, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[1.4, 7.3], [2.1, 7.3], [1.75, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[2.1, 7.3], [2.8, 7.3], [2.45, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[2.8, 7.3], [3.5, 7.3], [3.15, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[3.5, 7.3], [4.2, 7.3], [3.85, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[4.2, 7.3], [4.9, 7.3], [4.55, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[4.9, 7.3], [5.6, 7.3], [5.25, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[5.6, 7.3], [6.3, 7.3], [5.95, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: poly, points: [[6.3, 7.3], [7.0, 7.3], [6.65, 6.75]], y: [-0.08, 0.08], collide: 0}
      - {kind: rod, from: [-7.2, 0, 7.8], to: [-6.2, 0, 15.2], radius: 0.45, collide: 0}   # the bow's cheeks
      - {kind: rod, from: [7.2, 0, 7.8], to: [6.2, 0, 15.2], radius: 0.45, collide: 0}
      - {kind: rod, from: [-6.2, 0, 15.2], to: [-7.3, 0, 16.4], radius: 0.55, collide: 0}   # their handles
      - {kind: rod, from: [6.2, 0, 15.2], to: [7.3, 0, 16.4], radius: 0.55, collide: 0}
      - {kind: rod, from: [-6.7, 0, 11.6], to: [6.7, 0, 11.6], radius: 0.35, collide: 0}   # its stretcher
      - {kind: rod, from: [-6.3, 0, 14.6], to: [6.3, 0, 14.6], radius: 0.12, collide: 0, color: "#6f5a3e"}   # its cord
  - id: pendulum
    shape: part
    pos: [-23.0, 0, 33.5]
    mass: 1.5
    color: "#7d7466"
    pieces:
      - {kind: rod, from: [-23.0, 0, 33.5], to: [-23.0, 0, 9.5], radius: 0.4, collide: 0}   # the pendulum
      - {kind: poly, points: [[-25.3, 3.0], [-20.7, 3.0], [-20.9, 8.5], [-22.4, 9.6], [-23.6, 9.6], [-25.1, 8.5]], y: [-0.7, 0.7], collide: 0}   # its bob
      - {kind: rod, from: [-23.0, -0.6, 16.0], to: [-22.3, -0.6, 16.0], radius: 0.22, collide: 0}   # its pin-holes
      - {kind: rod, from: [-23.0, -0.6, 14.0], to: [-22.3, -0.6, 14.0], radius: 0.22, collide: 0}
  - id: link
    shape: part
    mount: pendulum
    pos: [-23.0, 0, 12.0]
    mass: 0.1
    color: "#6b6258"
    pieces:
      - {kind: rod, from: [-23.0, -0.9, 12.0], to: [-7.0, -0.9, 11.0], radius: 0.35, collide: 0}   # the link
      - {kind: disc, center: [-7.0, 11.0], radius: 0.6, y: [-1.2, -0.6], collide: 0, color: "#55504a"}
  - id: wl
    shape: part
    pos: [-17.0, 0, 11.0]
    mass: 0.85
    color: "#6b6258"
    pieces:
      - {kind: poly, points: [[-18.3, 7.6], [-15.7, 7.6], [-15.7, 11.0], [-18.3, 11.0]], y: [-1.2, 1.2], collide: 0}   # the counterweights
  - id: wr
    shape: part
    pos: [17.0, 0, 11.0]
    mass: 0.85
    color: "#6b6258"
    pieces:
      - {kind: poly, points: [[15.7, 7.6], [18.3, 7.6], [18.3, 11.0], [15.7, 11.0]], y: [-1.2, 1.2], collide: 0}
joints:
  - {id: j_p, type: hinge, body: pendulum, axis: [0, 1, 0], damping: 0.01}   # the pendulum, swung to and fro (the one driven joint)
  - {id: j_l, type: hinge, body: link, axis: [0, 1, 0], damping: 0.001}
  - {id: j_c, type: slide, body: carriage, axis: [0, 0, 1], damping: 0.5}   # the carriage, on its cords
  - {id: j_s, type: slide, body: saw, axis: [1, 0, 0], damping: 0.05}   # the saw, to and fro in it
  - {id: j_wl, type: slide, body: wl, axis: [0, 0, 1], damping: 0.1}
  - {id: j_wr, type: slide, body: wr, axis: [0, 0, 1], damping: 0.1}
pins:
  - {id: p_saw, a: link, b: saw, at: [-7.0, 0, 11.0]}
ropes:
  - {id: cord_l, from: {body: carriage, at: [-13.0, 0, 18.6]}, over: {center: [-15.0, 0, 22.0], radius: 2.0, axis: y, side: [-15.0, 0, 25.0]}, to: {body: wl, at: [-17.0, 0, 11.0]}, width: 0.25, thickness: 0.25}
  - {id: cord_r, from: {body: carriage, at: [13.0, 0, 18.6]}, over: {center: [15.0, 0, 22.0], radius: 2.0, axis: y, side: [15.0, 0, 25.0]}, to: {body: wr, at: [17.0, 0, 11.0]}, width: 0.25, thickness: 0.25}
contact: {solref: [0.004, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_p, kind: velocity, rpm: 0, swing: {amplitude: 0.25, hz: 0.8}, kv: 2.0, max_torque: 5.0}
checks:
  - {type: ratio, out: j_s, in: j_p, expect: -0.215, tol: 0.03, settle_s: 2, window_s: 7}   # the saw strokes with the pendulum
  - {type: position, joint: j_c, min: -0.1, max: 0.1, settle_s: 1, window_s: 8}   # it stays on the cut
  - {type: penetration, max: 0.0015, settle_s: 0.5}
camera: {target: [-8.0, 0, 9.0], position: [-8.0, -120.0, 15.0], fov: 34}
display:
  output: j_s
  labels: {j_p: "Pendulum (driver)", j_s: "Saw", j_c: "Carriage"}

