# No. 403 (Brown 1868): "Cyclograph for describing circular arcs in drawings where the center is inaccessible. This is composed of three straight
# rules. The chord and versed sine being laid down, draw straight sloping lines from ends of former to top of latter, and to these lines lay two of
# the rules crossing at the apex. Fasten these rules together, and another rule across them to serve as a brace, and insert a pin or point at each
# end of chord to guide the apparatus, which, on being moved against these points, will describe the arc by means of pencil in the angle of the
# crossing edges of the sloping rules."
#
# Model (cm, a plan view: the apparatus lies flat on the drawing, so no gravity): chord 30, versed sine 9; the two sloping rules, crossing
# at the apex, and the brace are one rigid frame, free to slide and turn on the paper (two slides and a turn). Two needle points stand at the
# chord's ends. The hand (the one driven joint) moves the frame to and fro across the paper (3.6 cm either way) and presses it lightly
# down against the needles (a soft spring, 2 N/m, its rest 30 cm below); the needles alone set how high it lies and how it turns, and the
# pencil in the angle of the edges describes the arc: the angle at the pencil stays the same, so it lies on the circle through the needles. A light
# readout from the (inaccessible) centre, pinned at the pencil, records the pencil's distance from it; it carries nothing.
# Generator: opencode-runs/batch13/gen403.py.
number: 403
slug: cyclograph-three-rules
name: Cyclograph of three rules for arcs whose centre is inaccessible
brown: "Cyclograph for describing circular arcs in drawings where the center is inaccessible. This is composed of three straight rules. The chord and versed sine being laid down, draw straight sloping lines from ends of former to top of latter, and to these lines lay two of the rules crossing at the apex. Fasten these rules together, and another rule across them to serve as a brace, and insert a pin or point at each end of chord to guide the apparatus, which, on being moved against these points, will describe the arc by means of pencil in the angle of the crossing edges of the sloping rules."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 60, duration_s: 10.5, floor: false, gravity: 0}
bodies:
  - id: paper
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#efe8d8"
    pieces:
      - {kind: poly, points: [[-15, -0.04], [15, -0.04], [15, 0.04], [-15, 0.04]], y: [0.55, 0.6], color: "#8f8a80"}   # the chord laid down
      - {kind: poly, points: [[-0.04, 0], [0.04, 0], [0.04, 9], [-0.04, 9]], y: [0.55, 0.6], color: "#8f8a80"}   # the versed sine
      - {kind: poly, points: [[-15.0676, 0.0361], [-14.6905, 0.7062], [-14.7594, 0.747], [-15.1382, 0.0737]], y: [0.55, 0.6], color: "#3a3632"}   # the arc being described
      - {kind: poly, points: [[-14.6905, 0.7062], [-14.2837, 1.3588], [-14.3506, 1.4026], [-14.7594, 0.747]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-14.2837, 1.3588], [-13.8479, 1.9923], [-13.9128, 2.0392], [-14.3506, 1.4026]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-13.8479, 1.9923], [-13.384, 2.6056], [-13.4467, 2.6553], [-13.9128, 2.0392]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-13.384, 2.6056], [-12.893, 3.1974], [-12.9534, 3.2499], [-13.4467, 2.6553]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-12.893, 3.1974], [-12.3758, 3.7665], [-12.4338, 3.8216], [-12.9534, 3.2499]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-12.3758, 3.7665], [-11.8335, 4.3117], [-11.8889, 4.3694], [-12.4338, 3.8216]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-11.8335, 4.3117], [-11.2672, 4.832], [-11.32, 4.8921], [-11.8889, 4.3694]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-11.2672, 4.832], [-10.6781, 5.3262], [-10.7281, 5.3887], [-11.32, 4.8921]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-10.6781, 5.3262], [-10.0674, 5.7935], [-10.1145, 5.8581], [-10.7281, 5.3887]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-10.0674, 5.7935], [-9.4362, 6.2327], [-9.4804, 6.2994], [-10.1145, 5.8581]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-9.4362, 6.2327], [-8.7858, 6.6431], [-8.827, 6.7117], [-9.4804, 6.2994]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-8.7858, 6.6431], [-8.1177, 7.0238], [-8.1557, 7.0942], [-8.827, 6.7117]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-8.1177, 7.0238], [-7.4331, 7.374], [-7.4679, 7.446], [-8.1557, 7.0942]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-7.4331, 7.374], [-6.7334, 7.693], [-6.765, 7.7666], [-7.4679, 7.446]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-6.7334, 7.693], [-6.0201, 7.9803], [-6.0483, 8.0551], [-6.765, 7.7666]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-6.0201, 7.9803], [-5.2946, 8.2351], [-5.3194, 8.3112], [-6.0483, 8.0551]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-5.2946, 8.2351], [-4.5583, 8.457], [-4.5797, 8.5341], [-5.3194, 8.3112]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-4.5583, 8.457], [-3.8128, 8.6455], [-3.8307, 8.7235], [-4.5797, 8.5341]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-3.8128, 8.6455], [-3.0596, 8.8003], [-3.0739, 8.879], [-3.8307, 8.7235]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-3.0596, 8.8003], [-2.3001, 8.921], [-2.3109, 9.0003], [-3.0739, 8.879]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-2.3001, 8.921], [-1.536, 9.0074], [-1.5432, 9.0871], [-2.3109, 9.0003]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-1.536, 9.0074], [-0.7688, 9.0593], [-0.7724, 9.1392], [-1.5432, 9.0871]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[-0.7688, 9.0593], [0.0, 9.0766], [0.0, 9.1566], [-0.7724, 9.1392]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[0.0, 9.0766], [0.7688, 9.0593], [0.7724, 9.1392], [0.0, 9.1566]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[0.7688, 9.0593], [1.536, 9.0074], [1.5432, 9.0871], [0.7724, 9.1392]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[1.536, 9.0074], [2.3001, 8.921], [2.3109, 9.0003], [1.5432, 9.0871]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[2.3001, 8.921], [3.0596, 8.8003], [3.0739, 8.879], [2.3109, 9.0003]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[3.0596, 8.8003], [3.8128, 8.6455], [3.8307, 8.7235], [3.0739, 8.879]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[3.8128, 8.6455], [4.5583, 8.457], [4.5797, 8.5341], [3.8307, 8.7235]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[4.5583, 8.457], [5.2946, 8.2351], [5.3194, 8.3112], [4.5797, 8.5341]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[5.2946, 8.2351], [6.0201, 7.9803], [6.0483, 8.0551], [5.3194, 8.3112]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[6.0201, 7.9803], [6.7334, 7.693], [6.765, 7.7666], [6.0483, 8.0551]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[6.7334, 7.693], [7.4331, 7.374], [7.4679, 7.446], [6.765, 7.7666]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[7.4331, 7.374], [8.1177, 7.0238], [8.1557, 7.0942], [7.4679, 7.446]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[8.1177, 7.0238], [8.7858, 6.6431], [8.827, 6.7117], [8.1557, 7.0942]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[8.7858, 6.6431], [9.4362, 6.2327], [9.4804, 6.2994], [8.827, 6.7117]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[9.4362, 6.2327], [10.0674, 5.7935], [10.1145, 5.8581], [9.4804, 6.2994]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[10.0674, 5.7935], [10.6781, 5.3262], [10.7281, 5.3887], [10.1145, 5.8581]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[10.6781, 5.3262], [11.2672, 4.832], [11.32, 4.8921], [10.7281, 5.3887]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[11.2672, 4.832], [11.8335, 4.3117], [11.8889, 4.3694], [11.32, 4.8921]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[11.8335, 4.3117], [12.3758, 3.7665], [12.4338, 3.8216], [11.8889, 4.3694]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[12.3758, 3.7665], [12.893, 3.1974], [12.9534, 3.2499], [12.4338, 3.8216]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[12.893, 3.1974], [13.384, 2.6056], [13.4467, 2.6553], [12.9534, 3.2499]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[13.384, 2.6056], [13.8479, 1.9923], [13.9128, 2.0392], [13.4467, 2.6553]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[13.8479, 1.9923], [14.2837, 1.3588], [14.3506, 1.4026], [13.9128, 2.0392]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[14.2837, 1.3588], [14.6905, 0.7062], [14.7594, 0.747], [14.3506, 1.4026]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: poly, points: [[14.6905, 0.7062], [15.0676, 0.0361], [15.1382, 0.0737], [14.7594, 0.747]], y: [0.55, 0.6], color: "#3a3632"}
      - {kind: rod, from: [-15, -0.8, 0], to: [-15, 0.6, 0], radius: 0.1, capsule: true, collide: 2, color: "#5c5244"}   # the needle at one end of the chord
      - {kind: rod, from: [15, -0.8, 0], to: [15, 0.6, 0], radius: 0.1, capsule: true, collide: 2, color: "#5c5244"}   # and at the other
      - {kind: disc, center: [-15, 0], radius: 0.35, y: [-1.0, -0.8], color: "#5c5244"}
      - {kind: disc, center: [15, 0], radius: 0.35, y: [-1.0, -0.8], color: "#5c5244"}
  - {id: fx, shape: part, pos: [0, 0, 9.1166], mass: 0.002, pieces: [{kind: rod, from: [0, -2, 9.1166], to: [0, -1.95, 9.1166], radius: 0.05}]}
  - {id: fz, shape: part, pos: [0, 0, 9.1166], mount: fx, mass: 0.002, pieces: [{kind: rod, from: [0, -2, 9.1166], to: [0, -1.95, 9.1166], radius: 0.05}]}
  - id: frame
    shape: part
    pos: [0, 0, 9.1166]
    mount: fz
    density: 700
    color: "#e6dcc4"
    pieces:
      - {kind: poly, points: [[-20.7514, -3.3343], [3.8073, 11.401], [3.0355, 12.6872], [-21.5232, -2.048]], y: [0.0, 0.45], collide: 1}   # the sloping rule laid to the line from one end of the chord
      - {kind: poly, points: [[20.7514, -3.3343], [-3.8073, 11.401], [-3.0355, 12.6872], [21.5232, -2.048]], y: [-0.45, 0.0], collide: 1}   # and the one from the other end, crossing it at the apex
      - {kind: poly, points: [[-19.2043, -2.7728], [19.2043, -2.7728], [19.2043, -1.5728], [-19.2043, -1.5728]], y: [-0.9, -0.45]}   # the brace across them
      - {kind: rod, from: [0, -1.6, 9.1166], to: [0, 0.55, 9.1166], radius: 0.18, color: "#3a3632"}   # the pencil in the angle of the crossing edges
  - {id: rd_arm, shape: part, pos: [0, 0, -8.0], mass: 0.002, pieces: [{kind: rod, from: [0, -2, -8.0], to: [0, -1.95, -8.0], radius: 0.05}]}
  - {id: rd_rad, shape: part, pos: [0, 0, 9.1166], mount: rd_arm, mass: 0.002, pieces: [{kind: rod, from: [0, -2, 9.1166], to: [0, -1.95, 9.1166], radius: 0.05}]}
pins:
  - {id: p_read, a: rd_rad, b: frame, at: [0, 0, 9.1166]}   # the readout at the pencil
joints:
  - {id: j_x, type: slide, body: fx, axis: [1, 0, 0], damping: 0.05}   # the one driven joint: the hand moves the apparatus across the paper
  - {id: j_z, type: slide, body: fz, axis: [0, 0, 1], range: [-3, 1], stiffness: 2, springref: -30, damping: 0.05}   # and presses it lightly against the needles (the hand keeps it within 3 cm)
  - {id: j_f, type: hinge, body: frame, axis: [0, -1, 0], damping: 0.1}   # the frame turns on the paper (its drag on the paper)
  - {id: j_rd, type: hinge, body: rd_arm, axis: [0, -1, 0]}   # readout: the pencil's bearing from the centre
  - {id: j_r, type: slide, body: rd_rad, axis: [0, 0, 1]}   # readout: the pencil's distance from the centre, less 17.1166
driver: {joint: j_x, kind: velocity, rpm: 0, swing: {amplitude: 0.0452, hz: 0.2}, kv: 200, max_torque: 20}
checks:
  - {type: position, joint: j_r, min: -0.02, max: 0.02, settle_s: 0.5, window_s: 10}   # the pencil keeps its distance from the centre: it describes the arc
  - {type: follow, out: j_f, in: j_rd, expect: 0.5, tol: 0.01, min_r2: 0.999, settle_s: 0.5, window_s: 10}   # the rules turn half as far as the pencil goes round the centre (the angle in the segment)
  - {type: amplitude, joint: j_rd, min: 0.15, max: 0.3, sustain: 0.7, settle_s: 0.5, window_s: 10}   # the pencil swept well along the arc
  - {type: penetration, max: 0.002, settle_s: 0.5}
camera: {target: [0, 0, 3], position: [0, -80, 3], fov: 34}
display:
  output: j_r
  labels: {j_x: "The hand (driver)", j_z: "The hand's press", j_f: "The rules turning", j_rd: "Pencil's bearing from the centre", j_r: "Pencil's distance from the centre"}

