Techniqueadvanced
Standard form dyad synthesis
Also called complex number dyad synthesis, Erdman-Sandor dyad method.
Writes each side of a linkage as a dyad of two complex vectors and solves the loop equations for the given positions, linear for up to three positions.
Standard form dyad synthesis designs a planar linkage one side at a time. Each side is a dyad: a grounded link and a vector from its moving pivot to the precision point, both written as complex numbers. If the link turns by and the coupler by between position 1 and position , the loop closure gives the standard form , with . For two or three positions the designer picks the free rotations and the standard form is a linear system for and ; for four and five positions it leads to Burmester theory.
In plain words
A four-bar is two arms joined by a middle piece. Each arm is fixed to the ground at one end and turns about that pivot. The middle piece carries the point or the part that must move.
This method looks at one arm and the line from its end to the moving point. It writes both as arrows, with a length and a direction. When the linkage moves to a new position, each arrow turns by some angle, and the arrows must still end at the new point. That gives one equation per new position.
If you choose how far the arm turns, the equations become simple and you can solve them exactly by hand. You then repeat the work for the other arm and join the two arms with the middle piece.
When it applies
- The task is motion generation, path generation with prescribed timing, or function generation, for a planar linkage made of dyads (four-bars, slider-cranks, and the loops of six-bars).
- The number of positions is two or three, so that the system is linear after the free choices. With four or five positions the same equations are still the right model, but they are nonlinear.
- The rotations that the task does not give are free choices of the designer. In motion generation the coupler rotations are given and the link rotations are free; in path generation with timing the of the input are given and the are free.
The template
The input is the three precision points , the coupler rotations , and the link rotations , of which some are free choices.
STANDARD-FORM-DYAD(P1, P2, P3, α2, α3, β2, β3)- 1
for j ∈ {2, 3}: Bj ← e^{iβj} − 1; Aj ← e^{iαj} − 1; δj ← Pj − P1 - 2
D ← B2·A3 − B3·A2 - 3
if D = 0 then return "singular: change the free choices" - 4
W ← (δ2·A3 − δ3·A2)/D - 5
Z ← (B2·δ3 − B3·δ2)/D - 6
G ← P1 − W − Z - 7
return the fixed pivot G, the link W and the vector Z
Line L1 forms the coefficients. Lines L2, L4 and L5 are Cramer's rule for the complex system of the standard form, and L3 rejects the singular case. Line L6 places the fixed pivot so that the dyad ends at in position 1. The moving pivot in position is , and is the length of the grounded link. Run the template twice, with two different sets of free choices but the same , to get two dyads. They share the coupler, so together they are a four-bar with ground , links and , and coupler .
Derivation from the loop closure
Put the fixed pivot at . In position 1 the dyad reaches the precision point by the link and then the coupler-side vector:
In position the grounded link has turned about by , which multiplies its vector by , and the coupler has turned by , which multiplies every vector fixed in the coupler by . The lengths stay the same because the links are rigid. So
Subtract the equation of position 1. The unknown pivot cancels, and
This is the standard form. It is the vector loop closure of the loop formed by the dyad in position 1, the dyad in position , and the displacement . Conversely, if and satisfy the standard form for each , then gives a dyad that reaches every with the coupler at the rotation , because adding the equation of position 1 back gives the equation of position .
The count of free choices
The unknowns of one dyad for positions are and (four reals) and the unknown rotations, one per position after the first (the in motion generation). Each position after the first gives one complex equation, so two real equations. The number of free real choices is
which is 3, 2, 1, 0 for . For two positions the designer picks and and solves one complex equation for . For three positions the designer picks and , and the template solves for and .
When the system is singular
The system has the matrix and determinant . It has a unique solution exactly when . With ,
so exactly when the rows and are proportional over the complex numbers. Cases that occur in practice:
- The link turns with the coupler, and . Then and enter only as , and the dyad is one rigid body turning about . It exists only if the three positions are rotations about one point.
- The link does not turn, . Then and drops out.
- The coupler does not turn, , a pure translation. Then drops out, and the task needs a parallelogram or other special linkage.
- Positions 2 and 3 have the same rotations, and .
When the system has no solution unless is the same multiple of , and then it has a one-parameter family. A close to zero gives very long links. The tests check that the template returns no dyad in each case above.
Cost
One three-position dyad is a fixed number of complex operations. With exact data (rotations that are rational points of the unit circle and rational points ), every step is exact in rational arithmetic, which the tests use.
Classic examples
Recovering a known four-bar. Take the four-bar with , , , , and the midpoint of the coupler, at its three exact positions from the kinematic synthesis page: , , . The coupler turns by and , with
With the input rotations and ( and ), the template returns, in exact rational arithmetic,
which is the input link and the half coupler from to . With the output rotations and ( and ) it returns , , , the output link and the half coupler from to .
A new dyad by a free choice. Keep the same positions and pick , . In floating point, the template gives , with , and . The dyad reaches the three points with errors below . Joined with the output dyad above, it gives a four-bar with ground , links and , and coupler , a Grashof linkage whose shortest link is the coupler. Driving the new link through , , in 3000 steps moves the linkage through the three positions on one branch. The transmission angle at the three positions is , and , so position 1 is close to a toggle and the design would be rejected. The free choices must be searched with this check, which is what design programs do.
Two positions. For two positions the designer chooses and . Then , one complex division. The motion generation page has a two-position example worked with the perpendicular bisector, which is the graphical form of the same equation.
Path generation with prescribed timing. For path generation with timing the of the input dyad are data and the are free. For three points the designer picks , and the same template applies with the roles of the choices exchanged. The output dyad then uses the same and its own free .
Function generation. For function generation with three precision points, put the precision point at the moving pivot of the output link in the frame of the input link (a kinematic inversion). The relative rotations play the role of and , and the template gives the coupler and the output link.
Variations
- Four positions. A third equation must be consistent with the first two. The condition is that the complex determinant of the rows vanishes, one complex equation in . One real choice remains, and the solutions trace the circle-point and center-point curves of Burmester theory.
- Five positions. Two such determinants must vanish, and the solutions are the at most four Burmester dyads.
- Prescribed fixed pivot. If the designer fixes and not the rotations, the equations are nonlinear in the . Write with unknown and use the inverse motion; for three positions this is again a center-of-circle construction.
- Slider dyads. A prismatic joint replaces by with a fixed direction and unknown slides , which gives the slider-crank form of the same method.
- Six-bars. Each loop of a Watt or Stephenson chain is written as dyads, and the method is applied loop by loop.
Pitfalls
- Wrong sign of the rotations. All rotations are measured counterclockwise from position 1. A taken from the wrong end of the link or in the wrong sense gives a dyad that fits other positions.
- Singular or near singular choices. The cases listed above, and any choice with small, give no dyad or very long links. Check before you accept the result.
- Each dyad is checked alone. The template proves only that each dyad reaches each position. The four-bar made of two dyads can still have a branch defect, an order defect, or a poor transmission angle, as in the second example. Simulate the four-bar through the positions.
- Free choices are not neutral. The two free values for three positions move the fixed pivot over the plane. Pick them by a search with the side conditions, not by habit.
- Floating point and exact data. With rotations given in degrees the computed are rounded, and the residuals are of order times the size of the dyad. With rational points of the unit circle the method is exact.
Code
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/standard-form-dyad-synthesis/. The authors are listed in prov/PC7C1B.jsonl.
"""Standard form dyad synthesis for three positions.
A dyad is a grounded link W (from the fixed pivot G to the moving pivot) and a
coupler-side vector Z (from the moving pivot to the precision point). In
position j the link has turned by beta_j and the coupler by alpha_j from
position 1, so
G + W e^{i beta_j} + Z e^{i alpha_j} = P_j,
and subtracting position 1 gives the standard form
W (e^{i beta_j} - 1) + Z (e^{i alpha_j} - 1) = delta_j = P_j - P_1.
Rotations are passed as unit numbers u = e^{i angle}, not as angles, so the
same code runs on Python complex numbers and on exact QC numbers (complex
numbers with Fraction parts), with rational points of the unit circle.
"""
import math
from fractions import Fraction
class QC:
"""An exact complex number with Fraction real and imaginary parts."""
__slots__ = ("re", "im")
def __init__(self, re, im=0):
self.re = Fraction(re)
self.im = Fraction(im)
@staticmethod
def of(z):
return z if isinstance(z, QC) else QC(z)
def __add__(self, o):
o = QC.of(o)
return QC(self.re + o.re, self.im + o.im)
__radd__ = __add__
def __sub__(self, o):
o = QC.of(o)
return QC(self.re - o.re, self.im - o.im)
def __rsub__(self, o):
return QC.of(o) - self
def __neg__(self):
return QC(-self.re, -self.im)
def __mul__(self, o):
o = QC.of(o)
return QC(self.re * o.re - self.im * o.im, self.re * o.im + self.im * o.re)
__rmul__ = __mul__
def __truediv__(self, o):
o = QC.of(o)
n = o.re * o.re + o.im * o.im
if n == 0:
raise ZeroDivisionError("division by zero")
return QC((self.re * o.re + self.im * o.im) / n, (self.im * o.re - self.re * o.im) / n)
def __eq__(self, o):
if isinstance(o, (int, Fraction)):
o = QC(o)
return isinstance(o, QC) and self.re == o.re and self.im == o.im
def __hash__(self):
return hash((self.re, self.im))
def conj(self):
return QC(self.re, -self.im)
def abs2(self):
return self.re * self.re + self.im * self.im
def __repr__(self):
return "QC(%s, %s)" % (self.re, self.im)
def rational_unit(t):
"""The point ((1 - t^2)/(1 + t^2), 2t/(1 + t^2)) of the unit circle, e^{i angle} with tan(angle/2) = t."""
t = Fraction(t)
return QC((1 - t * t) / (1 + t * t), 2 * t / (1 + t * t))
def unit(angle):
"""e^{i angle} as a Python complex number."""
return complex(math.cos(angle), math.sin(angle))
def is_zero(z, tol):
if isinstance(z, QC):
return z.re == 0 and z.im == 0
return abs(z) <= tol
def three_position_dyad(p1, p2, p3, a2, a3, b2, b3, tol=1e-12):
"""Solve the 2 x 2 standard form system for (G, W, Z), or None when it is singular.
p1, p2, p3 are the precision points; a2, a3 the coupler rotations e^{i alpha_j};
b2, b3 the link rotations e^{i beta_j}. tol is the singularity test for floats.
"""
d2, d3 = p2 - p1, p3 - p1
bb2, aa2 = b2 - 1, a2 - 1 # @line L1
bb3, aa3 = b3 - 1, a3 - 1
det = bb2 * aa3 - bb3 * aa2 # @line L2
scale = 1.0 if isinstance(det, QC) else max(1.0, abs(bb2) * abs(aa3) + abs(bb3) * abs(aa2))
if is_zero(det, tol * scale): # @line L3
return None
w = (d2 * aa3 - d3 * aa2) / det # @line L4
z = (bb2 * d3 - bb3 * d2) / det # @line L5
g = p1 - w - z # @line L6
return g, w, z # @line L7
def two_position_dyad(p1, p2, a2, b2, z, tol=1e-12):
"""Two positions: with Z and beta_2 chosen, W = (delta_2 - Z (e^{i alpha_2} - 1)) / (e^{i beta_2} - 1)."""
bb2 = b2 - 1
if is_zero(bb2, tol):
return None
w = (p2 - p1 - z * (a2 - 1)) / bb2
return p1 - w - z, w, z
def dyad_point(g, w, z, a, b):
"""The precision point of the dyad when the link has turned by b and the coupler by a."""
return g + w * b + z * a
def free_choices(n):
"""Free real parameters of one dyad for n positions in motion generation: 5 - n."""
unknowns = 4 + (n - 1)
equations = 2 * (n - 1)
return unknowns - equations
def four_bar(dyad_a, dyad_b):
"""Ground pivots and link lengths of the four-bar made of two dyads that share the coupler.
Returns (G_A, G_B, |W_A|, |W_B|, coupler length |Z_A - Z_B|) for complex dyads.
"""
ga, wa, za = dyad_a
gb, wb, zb = dyad_b
return ga, gb, abs(wa), abs(wb), abs(za - zb)
test_standard_form_dyad_synthesis.py 205 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/standard-form-dyad-synthesis/. The authors are listed in prov/PC7C1B.jsonl.
import cmath
import math
import random
import unittest
from fractions import Fraction
from standard_form_dyad_synthesis import (
QC,
dyad_point,
four_bar,
free_choices,
rational_unit,
three_position_dyad,
two_position_dyad,
unit,
)
def gauss_real(m, r):
"""Oracle: Gaussian elimination with partial pivoting on a real square system; None if singular."""
n = len(m)
a = [list(row) + [rhs] for row, rhs in zip(m, r)]
for col in range(n):
piv = max(range(col, n), key=lambda i: abs(a[i][col]))
if abs(a[piv][col]) < 1e-13:
return None
a[col], a[piv] = a[piv], a[col]
for i in range(col + 1, n):
f = a[i][col] / a[col][col]
for k in range(col, n + 1):
a[i][k] -= f * a[col][k]
x = [0.0] * n
for i in range(n - 1, -1, -1):
x[i] = (a[i][n] - sum(a[i][k] * x[k] for k in range(i + 1, n))) / a[i][i]
return x
def oracle_wz(p1, p2, p3, a2, a3, b2, b3):
"""Oracle: the standard form as four real equations in Wx, Wy, Zx, Zy."""
rows, rhs = [], []
for p, a, b in ((p2, a2, b2), (p3, a3, b3)):
bb, aa, d = b - 1, a - 1, p - p1
# (bb)(Wx + i Wy) + (aa)(Zx + i Zy) = d, split into real and imaginary parts.
rows.append([bb.real, -bb.imag, aa.real, -aa.imag])
rhs.append(d.real)
rows.append([bb.imag, bb.real, aa.imag, aa.real])
rhs.append(d.imag)
x = gauss_real(rows, rhs)
if x is None:
return None
return complex(x[0], x[1]), complex(x[2], x[3])
def rand_rational(rng, lo=-9, hi=9, den=7):
return Fraction(rng.randint(lo * den, hi * den), rng.randint(1, den))
def rand_qc(rng):
return QC(rand_rational(rng), rand_rational(rng))
class TestExact(unittest.TestCase):
def setUp(self):
# Coupler of the four-bar O2 = (0, 0), O4 = (9, 0), a = 15, b = 5, c = 13; P is the midpoint of AB.
self.p = [QC(Fraction(72, 5), Fraction(97, 10)), QC(Fraction(23, 2), 12), QC(2, Fraction(27, 2))]
e3 = [QC(Fraction(24, 25), Fraction(7, 25)), QC(1), QC(Fraction(4, 5), Fraction(-3, 5))]
self.alpha = [e3[j] / e3[0] for j in range(3)]
e2 = [QC(Fraction(4, 5), Fraction(3, 5)), QC(Fraction(3, 5), Fraction(4, 5)), QC(0, 1)]
e4 = [QC(Fraction(3, 5), Fraction(4, 5)), QC(Fraction(5, 13), Fraction(12, 13)), QC(Fraction(-5, 13), Fraction(12, 13))]
self.beta_a = [e2[j] / e2[0] for j in range(3)]
self.beta_b = [e4[j] / e4[0] for j in range(3)]
def solve(self, beta):
p, al = self.p, self.alpha
return three_position_dyad(p[0], p[1], p[2], al[1], al[2], beta[1], beta[2])
def test_recovers_the_two_sides_of_the_four_bar(self):
g, w, z = self.solve(self.beta_a)
self.assertEqual((g, w, z), (QC(0), QC(12, 9), QC(Fraction(12, 5), Fraction(7, 10))))
g, w, z = self.solve(self.beta_b)
self.assertEqual((g, w, z), (QC(9), QC(Fraction(39, 5), Fraction(52, 5)), QC(Fraction(-12, 5), Fraction(-7, 10))))
def test_rotations_are_the_stated_values(self):
self.assertEqual(self.alpha[1], QC(Fraction(24, 25), Fraction(-7, 25)))
self.assertEqual(self.alpha[2], QC(Fraction(3, 5), Fraction(-4, 5)))
self.assertEqual(self.beta_a[1], QC(Fraction(24, 25), Fraction(7, 25)))
self.assertEqual(self.beta_b[2], QC(Fraction(33, 65), Fraction(56, 65)))
def test_dyads_reach_every_position_exactly(self):
for beta in (self.beta_a, self.beta_b):
g, w, z = self.solve(beta)
for j in range(3):
self.assertEqual(dyad_point(g, w, z, self.alpha[j], beta[j]), self.p[j])
def test_random_exact_dyads(self):
rng = random.Random(1)
checked = 0
for _ in range(300):
g, w, z = rand_qc(rng), rand_qc(rng), rand_qc(rng)
al = [QC(1)] + [rational_unit(rand_rational(rng, -3, 3, 5)) for _ in range(2)]
be = [QC(1)] + [rational_unit(rand_rational(rng, -3, 3, 5)) for _ in range(2)]
p = [dyad_point(g, w, z, al[j], be[j]) for j in range(3)]
out = three_position_dyad(p[0], p[1], p[2], al[1], al[2], be[1], be[2])
det = (be[1] - 1) * (al[2] - 1) - (be[2] - 1) * (al[1] - 1)
if det == 0:
self.assertIsNone(out)
continue
self.assertEqual(out, (g, w, z))
for j in range(3):
self.assertEqual(dyad_point(out[0], out[1], out[2], al[j], be[j]), p[j])
checked += 1
self.assertGreater(checked, 250)
def test_four_bar_of_two_exact_dyads(self):
da, db = self.solve(self.beta_a), self.solve(self.beta_b)
coupler = (da[2] - db[2]).abs2()
for j in range(3):
ma = da[0] + da[1] * self.beta_a[j]
mb = db[0] + db[1] * self.beta_b[j]
self.assertEqual((ma - mb).abs2(), coupler)
self.assertEqual((ma - da[0]).abs2(), Fraction(225))
self.assertEqual((mb - db[0]).abs2(), Fraction(169))
self.assertEqual(coupler, Fraction(25))
def test_exact_singular_cases(self):
p, al = self.p, self.alpha
# Link turning with the coupler.
self.assertIsNone(three_position_dyad(p[0], p[1], p[2], al[1], al[2], al[1], al[2]))
# Link that does not turn.
self.assertIsNone(three_position_dyad(p[0], p[1], p[2], al[1], al[2], QC(1), QC(1)))
# Coupler that does not turn.
self.assertIsNone(three_position_dyad(p[0], p[1], p[2], QC(1), QC(1), self.beta_a[1], self.beta_a[2]))
class TestFloat(unittest.TestCase):
def test_random_positions_against_real_oracle(self):
rng = random.Random(42)
for _ in range(2000):
p = [complex(rng.uniform(-10, 10), rng.uniform(-10, 10)) for _ in range(3)]
al = [1] + [unit(rng.uniform(-math.pi, math.pi)) for _ in range(2)]
be = [1] + [unit(rng.uniform(-math.pi, math.pi)) for _ in range(2)]
out = three_position_dyad(p[0], p[1], p[2], al[1], al[2], be[1], be[2])
ref = oracle_wz(p[0], p[1], p[2], al[1], al[2], be[1], be[2])
if out is None or ref is None:
continue
g, w, z = out
scale = 1 + abs(w) + abs(z)
self.assertLess(abs(w - ref[0]), 1e-9 * scale)
self.assertLess(abs(z - ref[1]), 1e-9 * scale)
for j in range(3):
self.assertLess(abs(dyad_point(g, w, z, al[j], be[j]) - p[j]), 1e-12 * scale * 10)
def test_example_with_chosen_rotations(self):
p = [14.4 + 9.7j, 11.5 + 12j, 2 + 13.5j]
th3 = [math.atan2(1.4, 4.8), 0.0, math.atan2(-3, 4)]
al = [unit(t - th3[0]) for t in th3]
be = [1, unit(math.radians(10)), unit(math.radians(60))]
g, w, z = three_position_dyad(p[0], p[1], p[2], al[1], al[2], be[1], be[2])
self.assertAlmostEqual(g.real, 16.9106, delta=1e-4)
self.assertAlmostEqual(g.imag, 2.2282, delta=1e-4)
self.assertAlmostEqual(abs(w), 11.9606, delta=1e-4)
for j in range(3):
self.assertLess(abs(dyad_point(g, w, z, al[j], be[j]) - p[j]), 1e-12)
# The moving pivot lies on a circle about G.
for j in range(3):
self.assertAlmostEqual(abs(w * be[j]), abs(w), delta=1e-12)
ga, gb, la, lb, lc = four_bar((g, w, z), (9 + 0j, 7.8 + 10.4j, -2.4 - 0.7j))
self.assertAlmostEqual(lb, 13.0, delta=1e-12)
self.assertAlmostEqual(lc, 4.8976, delta=1e-4)
def test_float_singular_and_near_singular(self):
p = [0j, 1 + 1j, 2 - 1j]
a2, a3 = unit(0.3), unit(0.8)
self.assertIsNone(three_position_dyad(p[0], p[1], p[2], a2, a3, a2, a3))
self.assertIsNone(three_position_dyad(p[0], p[1], p[2], 1, 1, unit(0.2), unit(0.5)))
out = three_position_dyad(p[0], p[1], p[2], a2, a3, unit(0.3 + 1e-3), a3)
self.assertIsNotNone(out)
self.assertGreater(abs(out[1]), 100.0)
def test_two_positions(self):
rng = random.Random(3)
for _ in range(500):
p1, p2, z = (complex(rng.uniform(-5, 5), rng.uniform(-5, 5)) for _ in range(3))
a2, b2 = unit(rng.uniform(-3, 3)), unit(rng.uniform(0.1, 3))
g, w, z2 = two_position_dyad(p1, p2, a2, b2, z)
self.assertLess(abs(dyad_point(g, w, z2, 1, 1) - p1), 1e-12 * (1 + abs(w)))
self.assertLess(abs(dyad_point(g, w, z2, a2, b2) - p2), 1e-11 * (1 + abs(w)))
self.assertIsNone(two_position_dyad(0j, 1j, unit(0.5), 1, 1 + 0j))
def test_free_choice_count(self):
self.assertEqual([free_choices(n) for n in (2, 3, 4, 5, 6)], [3, 2, 1, 0, -1])
def test_numbers_from_angles(self):
self.assertLess(abs(unit(math.atan2(3, 4)) - complex(0.8, 0.6)), 1e-15)
u = rational_unit(Fraction(1, 2))
self.assertEqual(u, QC(Fraction(3, 5), Fraction(4, 5)))
self.assertEqual(u.abs2(), 1)
self.assertLess(abs(cmath.phase(complex(float(u.re), float(u.im))) - 2 * math.atan(0.5)), 1e-15)
if __name__ == "__main__":
unittest.main()
Exercises
- Show that for three positions the fixed pivot found by the template is the center of the circle through the three positions of the moving pivot. Why is this the graphical method of the motion generation page?
- In the first example, choose and . Show that , and explain the result with the first singular case.
- Prove that when and , and that the system then has a solution only if .
- Write the condition for four positions as a determinant, and count its real equations and unknowns.
- Derive the standard form of a dyad whose grounded joint is prismatic, and solve it for three positions.
References
- Arthur G. Erdman, George N. Sandor and Sridhar Kota, Mechanism Design, Analysis and Synthesis, Volume 1, 4th edition, Prentice Hall, 2001, Chapter 8, Introduction to Kinematic Synthesis, Graphical and Linear Analytical Methods (the standard form of the dyad, the table of free choices, and three-position synthesis by Cramer's rule)
- Robert L. Norton, Design of Machinery, 6th edition, McGraw-Hill, 2019, Chapter 5 (two- and three-position motion generation by analytical synthesis with the W and Z dyads, and path generation with prescribed timing)
- J. Michael McCarthy and Gim Song Soh, Geometric Design of Linkages, 2nd edition, Springer, 2011, Chapter 5 (pp. 93 to 123), algebraic synthesis of planar chains
- Richard S. Hartenberg and Jacques Denavit, Kinematic Synthesis of Linkages, McGraw-Hill, New York, 1964, the chapters on the complex number method for finitely separated positions (general locator)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag PC7C1B Edit this page History Report an error Markdown