One Input Angle Can Give a Four-Bar Linkage Two Assemblies
Draw a two-centimetre input link at 60°. That fixes its endpoint, but it does not always fix the rest of a closed linkage. In this experiment two different positions of one joint satisfy exactly the same four bar lengths. A solver that returns only the first position has silently chosen an assembly.
A four-bar linkage is a closed chain of four ideal rigid links joined end to end. An ideal pin joint is a hinge that permits relative rotation while keeping the joined endpoints together. The ground link is the link held fixed. We solve positions in one plane using paper geometry and code; no linkage was manufactured or driven.
Set the geometry before choosing a solution
Use paper, a ruler, a compass, a pencil and Python 3.9 or later. A compass here is the drawing tool for circles, not a magnetic sensor. The code and behavior tests use only Python's standard library. CPython, Python's reference implementation, was used for the recorded host runs. Lengths are in centimetres (cm); the input angle θ (theta) is measured in degrees counterclockwise from the positive horizontal axis.
- Fix A=(0,0) and D=(4,0). The ground link AD is 4 cm.
- Make the input AB=2 cm, the coupler BC=3 cm and the output CD=2.5 cm. The coupler is the moving link between B and C; it does not attach directly to ground.
- At θ=60°, place B=(2cosθ,2sinθ)=(1,√3) cm. Cosine and sine give the horizontal and vertical components of a unit direction; multiply them by AB to locate B.
- Draw a circle centred at B with radius 3 cm and another centred at D with radius 2.5 cm. Every intersection is a candidate C because it is the required distance from both centres.

Calculate both intersections and name their branches
Let d be the centre distance |D−B|, r=BC=3 and s=CD=2.5. Define the unit direction e=(D−B)/d, pointing from B to D, and the perpendicular direction n=(−e_y,e_x), turned counterclockwise through 90°. For d≠0, subtracting the two circle equations gives the distance a from B to the common chord's midpoint along e:
a=(r²−s²+d²)/(2d), h²=r²−a², C±=B+a e±h n. The chord joins the two circle intersections; its half-length h is a perpendicular distance. The program evaluates h² with an equivalent factored expression, ((r+s−d)(r+s+d)(d−|r−s|)(d+|r−s|))/(4d²), after checking whether intersections can exist.
The axial calculation evaluates r²−s² as (r−s)(r+s), avoiding the subtraction of nearly equal large squares before dividing by a small centre distance.
A branch is one signed family of positions. Define its sign using the planar cross product, the signed scalar cross(D−B,C−B)=(Dₓ−Bₓ)(Cᵧ−Bᵧ)−(Dᵧ−Bᵧ)(Cₓ−Bₓ). Positive means the + branch, negative the − branch. The sign is relative to the oriented line B→D, not simply whether C is above the horizontal axis. It has units cm² and is used as a geometric label, not a torque.
| θ=60° result | Cₓ (cm) | Cᵧ (cm) | cross(D−B,C−B) (cm²) |
|---|---|---|---|
| + branch | 3.900566909 | 2.498021829 | +7.321842323 |
| − branch | 1.786933091 | −1.162899332 | −7.321842323 |
For each C the model also reports two closure residuals: calculated |C−B| minus 3 cm, and calculated |C−D| minus 2.5 cm. They are about 4.4×10⁻¹⁶ cm or zero in the recorded run. These tiny values describe floating-point arithmetic error in the calculation, not physical precision or manufacturing tolerance.
Find the boundary without inventing an impossible assembly
Two distinct circle intersections require |r−s|<d<r+s. At either equality the circles are tangent, touching at one point. If d>r+s the circles are separate; if d<|r−s| one lies strictly inside the other. Neither case has a real intersection. Equal centres and equal radii instead give coincident circles, sharing every point: infinitely many possibilities, not a single chosen point.
In the prescribed linkage, d²=(4−2cosθ)²+(2sinθ)²=20−16cosθ. Since d never drops below 2 cm, the inner boundary |3−2.5|=0.5 cm is never reached. The relevant outer boundary is d=3+2.5=5.5 cm. Therefore cosθ=(20−30.25)/16=−0.640625, giving θ≈129.838439977° in the displayed 0°…180° range. At this input the two signed positions meet at one tangent. At θ=180°, d=6 cm>5.5 cm, so the ideal assembly does not exist.

The graph displays only 0°…180°. The trigonometric geometry repeats every 360°; this is not a claim that the input can rotate through every angle while a physical linkage remains assembled. On a real mechanism the boundary may prevent further input motion. Our positional model does not calculate the effort or deformation that would result.
Run the paper and software controls
- Draw the fixed points and both circles at θ=60°. Mark both C positions before connecting A–B–C–D–A. Label each with the cross-product sign. Do not put a pin symbol where links merely cross.
- Extract the reader into one directory and run the commands below. A command-line interface (CLI) is a program controlled by typed commands. The file uses JavaScript Object Notation (JSON), a text format of named fields and lists; model lengths are parameters, and every numeric angle supplied in this experiment is explicitly constructed.
- Confirm classification
twoand two opposite signs for the baseline. Check both residuals on both positions, rather than checking only one bar. - Use the constructed zero-angle control: it still has two positions. Approach the boundary with 120°,125°,129°,129.8° and 129.83°, retaining the same sign as you compare successive positions. The branch separation shrinks; a single input angle still does not select the starting branch.
- At the calculated critical angle expect one numerical tangent. At180° expect
noneand an empty points list. Restore60° and confirm the two original positions return. - Run the blank observation template: its unknown angle yields
unknownandpoints:null. This differs from a constructed impossible angle, whose known geometry yieldsnoneandpoints:[]. Never turn an unknown angle into 0°.
python3 -B -m unittest -v test_fourbar_lab
python3 -B fourbar_lab.py data/constructed-angles.json
python3 -B fourbar_lab.py data/blank-observations.json
python3 -B fourbar_lab.py data/malformed-angle.json
python3 -B fourbar_lab.py data/constructed-angles.json
python3 -B generate_figures.py
The recorded host run passed 30 behavior tests. Tests cover both closure distances, both signs, external/internal tangency, separation/nesting, coincident circles, branch tracking near the boundary, reflection/periodicity, malformed/nonfinite inputs, units, duplicate records, blank unknowns and the actual CLI. This is software execution of a declared geometric model; no target firmware, motion hardware or manufactured linkage was tested.
Arithmetic, numerical tolerance and complete code
The model uses Python's binary64 floating-point numbers: finite-precision binary approximations, not exact symbolic geometry. It accepts lengths from 10⁻⁶ to 10⁶ cm, coordinate magnitudes and angle magnitudes up to 10⁶, at most 512 records and 1,000,000 input bytes. The reusable circle routine rejects nonzero centre separations below 10⁻⁹ cm. Its default absolute numerical tangency tolerance is 10⁻⁹ cm of transverse height h; within the closed intersection interval it reports a single numerical tangent when h is that small. This is an algorithmic classification threshold, not a clearance allowance.
Before returning any position, the code checks both closure residuals against the larger of the selected tolerance and 64 units in the last place (ULPs) at the coordinate/length scale, with a 1 cm minimum scale for this numerical budget. A ULP is the spacing between adjacent floating-point numbers at that scale. If either residual exceeds the budget, calculation fails explicitly; it does not report an inaccurate assembly. This numerical guard is not a physical-accuracy claim.
The outer and inner impossibility tests are strict and run first. Even a supplied d that exceeds r+s by 10⁻¹² cm returns none; the code never changes a negative geometric possibility into zero height. Near a boundary, rounding an input angle may change a classification. Report the actual input and residuals rather than claiming certainty about an exactly tangent physical mechanism. The one result represents numerical coalescence under the stated tolerance.
Full fourbar_lab.py source
#!/usr/bin/env python3
"""Ideal planar four-bar position model, centimetres and constructed angles."""
import argparse
import json
import math
from pathlib import Path
import re
import sys
ABS_TOL_CM = 1e-9
MAX_BYTES = 1_000_000
ID = re.compile(r"[A-Za-z0-9_-]{1,40}\Z")
def number(value, name, positive=False):
if isinstance(value, bool) or not isinstance(value, (int, float)):
raise ValueError(name + " must be a finite number")
try:
result = float(value)
except (OverflowError, ValueError):
raise ValueError(name + " is not a supported finite number")
if not math.isfinite(result) or abs(result) > 1e6:
raise ValueError(name + " must be finite with magnitude at most 1000000")
if positive and result < 1e-6:
raise ValueError(name + " length must be between 0.000001 and 1000000 cm")
return result
def center(value):
if not isinstance(value, (list, tuple)) or len(value) != 2:
raise ValueError("center must contain two coordinates in cm")
return tuple(number(v, "coordinate") for v in value)
def circle_intersections(B, D, r, s, tol_cm=ABS_TOL_CM):
"""Both intersections; strict outside/nested tests never clamp to tangent.
Inside the closed intersection interval, a transverse height <=tol_cm
is reported as one numerical tangent with its closure residuals.
Coincident means exactly equal input centers and radii (infinitely many).
"""
B, D = center(B), center(D)
r, s = number(r, "radius B", True), number(s, "radius D", True)
tol_cm = number(tol_cm, "tolerance")
if not 1e-12 <= tol_cm <= 1e-6:
raise ValueError("tolerance must be 1e-12..1e-6 cm")
dx, dy = D[0]-B[0], D[1]-B[1]
d = math.hypot(dx, dy)
out = {"center_distance_cm": d, "tolerance_cm": tol_cm, "points": []}
if d == 0:
out["classification"] = "coincident" if r == s else "none"
return out
if d < 1e-9:
raise ValueError("nonzero center separation below supported 1e-9 cm")
if d > r+s or d < abs(r-s):
out["classification"] = "none"
return out
ex, ey = dx/d, dy/d
a = ((r-s)*(r+s)+d*d)/(2*d)
# Both factors are nonnegative after the strict interval tests.
h2 = ((r+s-d)*(r+s+d)*(d-abs(r-s))*(d+abs(r-s)))/(4*d*d)
if h2 < 0 or not math.isfinite(h2):
raise ValueError("numerical intersection failed; no invented closure")
h = math.sqrt(h2)
base = (B[0]+a*ex, B[1]+a*ey)
signs = [(0, "tangent")] if h <= tol_cm else [(1, "+"), (-1, "-")]
out["classification"] = "one" if len(signs) == 1 else "two"
out["transverse_height_cm"] = h
for sign, branch in signs:
C = (base[0]-sign*h*ey, base[1]+sign*h*ex)
cross = dx*(C[1]-B[1])-dy*(C[0]-B[0])
residual_B, residual_D = math.dist(B,C)-r, math.dist(D,C)-s
scale = max(1.0, r, s, d, *(abs(v) for v in B+D+C))
closure_budget = max(tol_cm, 64*math.ulp(scale))
if (not all(math.isfinite(v) for v in C+(cross,residual_B,residual_D))
or max(abs(residual_B),abs(residual_D)) > closure_budget):
raise ValueError("numerically inaccurate closure; no position returned")
out["points"].append({"branch": branch, "C": list(C),
"cross_cm2": cross, "residual_B_cm": residual_B,
"residual_D_cm": residual_D})
return out
def assembly(theta_deg, ground=4, input_length=2, coupler=3, output=2.5):
theta = number(theta_deg, "theta_deg")
g = number(ground, "ground", True)
a = number(input_length, "input", True)
b = number(coupler, "coupler", True)
c = number(output, "output", True)
angle = math.radians(math.remainder(theta, 360))
B, D = (a*math.cos(angle), a*math.sin(angle)), (g, 0.0)
result = circle_intersections(B,D,b,c)
result.update(theta_deg=theta, units="cm", A=[0.0,0.0], B=list(B), D=list(D),
lengths={"ground":g,"input":a,"coupler":b,"output":c})
return result
def critical_angle_deg():
"""External tangency input angle of the prescribed 4/2/3/2.5 cm model."""
return math.degrees(math.acos((20-30.25)/16))
def fields(record, expected):
if not isinstance(record,dict) or set(record) != set(expected):
raise ValueError("missing/extra fields")
def analyze(document):
fields(document,("kind","units","lengths","records"))
if document["kind"] not in ("constructed","observation_blank") or document["units"] != "cm":
raise ValueError("use constructed/observation_blank and units cm")
lengths = document["lengths"]
fields(lengths,("ground","input","coupler","output"))
lengths = {k:number(v,k,True) for k,v in lengths.items()}
records = document["records"]
if not isinstance(records,list) or not 1 <= len(records) <= 512:
raise ValueError("need 1..512 records")
output, seen = [], set()
for record in records:
fields(record,("record_id","theta_deg"))
rid = record["record_id"]
if not isinstance(rid,str) or not ID.fullmatch(rid) or rid in seen:
raise ValueError("invalid/duplicate record_id")
seen.add(rid)
theta = record["theta_deg"]
if document["kind"] == "observation_blank" and theta is not None:
raise ValueError("blank observations cannot contain invented angles")
if theta is None:
result = {"theta_deg":None,"classification":"unknown","points":None}
else:
result = assembly(theta,lengths["ground"],lengths["input"],lengths["coupler"],lengths["output"])
output.append(dict(record_id=rid, **result))
return {"kind":document["kind"],"units":"cm","arithmetic":"Python binary64 floating point",
"tolerance_cm":ABS_TOL_CM,"records":output}
def no_duplicates(pairs):
result = {}
for k,v in pairs:
if k in result:
raise ValueError("duplicate JSON key: "+k)
result[k] = v
return result
def loads_strict(text):
return json.loads(text,object_pairs_hook=no_duplicates,
parse_constant=lambda x: (_ for _ in ()).throw(ValueError("nonfinite JSON: "+x)))
def read_document(path):
with Path(path).open("rb") as stream:
raw = stream.read(MAX_BYTES+1)
if len(raw) > MAX_BYTES:
raise ValueError("input exceeds 1000000 bytes")
return loads_strict(raw.decode("utf-8"))
def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("input",help="strict JSON constructed angles or blank template")
args = parser.parse_args(argv)
try:
result = analyze(read_document(args.input))
except (ValueError,OSError,UnicodeError) as error:
print("error: "+str(error),file=sys.stderr)
return 2
print(json.dumps(result,indent=2,allow_nan=False))
return 0
if __name__ == "__main__":
sys.exit(main())
Inject a fault, then restore the baseline
Make a copy of the constructed input. Change units from "cm" to "mm": the model rejects the unsupported unit instead of silently treating the lengths as centimetres. Change a positive length to zero, an angle to the string "NaN" (not a number), or repeat a record identifier: it must exit 2 with an error and no ordinary result. Decimal angle values in JSON are numbers here, unlike a text label. Restore the untouched constructed input after each fault and rerun 60°.
A missing observation is not a mechanism fault, and a drawn crossing is not a new constraint. To track an ideal branch, retain its declared sign and the starting assembly while staying away from tangency; simply sorting C points by page height is not a general branch rule. At tangency the sign reaches zero and the two branches meet, so this model alone cannot establish which physical continuation will occur. A sampling history also cannot establish unmodelled forces or collisions.
Challenge: why does the input fail at 180°?
Before running, calculate B and the centre distance. Could changing a branch sign rescue the geometry?
Answer: B=(−2,0) cm and D=(4,0) cm, so d=6 cm. The remaining two links span at most3+2.5=5.5 cm between B and D. Neither sign can close the0.5 cm shortfall. Both choices depend on the same circle intersection; selecting a sign cannot create one.
References and reproducible files
Carnegie Mellon University, Yi Zhang with Susan Finger and Stephannie Behrens, Introduction to Mechanisms, Chapter5, supplies the four-bar, fixed-frame and coupler terminology. The specific dimensions, circle equations, branch convention, graphs and code here are original and derived in the article. No university diagrams or manuals are bundled.
The related idler-gear direction experiment concerns ideal rotational ratios. Here the distinct outcome is positional ambiguity in a closed chain: the same input can satisfy two assemblies. The gear experiment is not evidence for four-bar force or clearance behavior.
Use the complete model, behavior tests, figure generator, constructed angles, blank observations, calculated graph data and source index. The generator creates both SVGs with the standard library; optional python3 -B generate_figures.py --png uses resvg_py to render PNGs. The explanatory text remains searchable Hypertext Markup Language (HTML), separate from the figures.