raw Math

A roller chain running around two sprockets — or just as well a conveyor belt, a timing belt, or a tank track — always traces the same basic shape: two straight sections tangent to both wheels, connected by an arc wrapped around each wheel. Given the two wheels as circles \(C_1(\mathbf{M}_1, r_1)\) and \(C_2(\mathbf{M}_2, r_2)\), this article derives that shape and its length, and animates individual chain links running around it.

Drag the small blue handles in the diagram to move a wheel, and the small red handles to resize it — the tangent lines, wrap angles, and total chain length recompute live for any pair of radii and positions.

Setting Up the Two Sprockets

Let \(\mathbf{M}_1,\mathbf{M}_2\) be the sprocket centers and \(r_1,r_2\) their radii. Define

\[\mathbf{d}:=\mathbf{M}_2-\mathbf{M}_1,\qquad d:=|\mathbf{d}|,\qquad \theta:=\operatorname{atan2}(d_y,d_x),\qquad s:=r_2-r_1.\]

\(d\) is the center distance, \(\theta\) the world-angle of the line connecting the two centers, and \(s\) the signed radius difference — positive when the second wheel is the larger one, negative when it's smaller, and zero when both wheels match. Using \(\operatorname{atan2}\) instead of a plain \(\tan^{-1}\) keeps the correct quadrant for every relative position of the two wheels, not only the ones where \(\mathbf{M}_2\) happens to lie to the right of \(\mathbf{M}_1\).

To place points on a circle's boundary, define the rotation \[\operatorname{Rot}(\alpha):=\begin{pmatrix}\cos\alpha\\\sin\alpha\end{pmatrix},\] a unit vector pointing at world-angle \(\alpha\). A point on circle \(C_i\) at world-angle \(\alpha\) is then simply \(\mathbf{M}_i+r_i\operatorname{Rot}(\alpha)\).

Finding the Common Tangent Line

The chain has to leave each wheel along a straight line that touches it, i.e. a common tangent to both circles. A line is tangent to a circle exactly where the radius to the touching point is perpendicular to it, and since the chain doesn't cross itself, both touching points share one common outward direction \(\hat{\mathbf{n}}=\operatorname{Rot}(\psi)\):

\[\mathbf{T}_1=\mathbf{M}_1+r_1\hat{\mathbf{n}},\qquad \mathbf{T}_2=\mathbf{M}_2+r_2\hat{\mathbf{n}}.\]

Requiring \(\mathbf{T}_2-\mathbf{T}_1\) — the tangent line's own direction — to be perpendicular to \(\hat{\mathbf{n}}\) gives, using \(\mathbf{T}_2-\mathbf{T}_1=\mathbf{d}+s\hat{\mathbf{n}}\) and \(\hat{\mathbf{n}}\cdot\hat{\mathbf{n}}=1\):

\[(\mathbf{d}+s\hat{\mathbf{n}})\cdot\hat{\mathbf{n}}=\mathbf{d}\cdot\hat{\mathbf{n}}+s=0\quad\Longrightarrow\quad \mathbf{d}\cdot\hat{\mathbf{n}}=-s.\]

Writing \(\hat{\mathbf{n}}=\operatorname{Rot}(\theta+\tfrac12\pi+\varphi)\) for an angle \(\varphi\) still to be determined, and \(\mathbf{d}=d\operatorname{Rot}(\theta)\), the left side becomes \(d\cos(\tfrac12\pi+\varphi)=-d\sin\varphi\), so \(-d\sin\varphi=-s\) and

\[\varphi=\sin^{-1}\!\left(\frac{s}{d}\right).\]

Because \(\mathbf{d}\cdot\hat{\mathbf{n}}=-s\) and \(|\mathbf{d}|=d\), decomposing \(\mathbf{d}\) into a part along \(\hat{\mathbf{n}}\) and a part perpendicular to it gives, by the Pythagorean theorem, a perpendicular part of length \(t:=\sqrt{d^2-s^2}\), i.e. \(\mathbf{d}=-s\hat{\mathbf{n}}+\mathbf{w}\) with \(\mathbf{w}\perp\hat{\mathbf{n}}\) and \(|\mathbf{w}|=t\). Substituting back:

\[\mathbf{T}_2-\mathbf{T}_1=\mathbf{d}+s\hat{\mathbf{n}}=(-s\hat{\mathbf{n}}+\mathbf{w})+s\hat{\mathbf{n}}=\mathbf{w},\]

so the tangent segment itself is exactly \(\mathbf{w}\), with length \(t\). Altogether:

\[\mathbf{T}_1=\mathbf{M}_1+r_1\operatorname{Rot}(\theta+\tfrac12\pi+\varphi),\qquad \mathbf{T}_2=\mathbf{M}_2+r_2\operatorname{Rot}(\theta+\tfrac12\pi+\varphi).\]

The whole two-wheel figure has a mirror symmetry across the line through \(\mathbf{M}_1\) and \(\mathbf{M}_2\), which produces the second common tangent by reflecting \(\hat{\mathbf{n}}\) to the other side, i.e. flipping the sign of \(\varphi\) and rotating by \(\pi\):

\[\mathbf{T}_1'=\mathbf{M}_1+r_1\operatorname{Rot}(\theta+\tfrac32\pi-\varphi),\qquad \mathbf{T}_2'=\mathbf{M}_2+r_2\operatorname{Rot}(\theta+\tfrac32\pi-\varphi).\]

Nothing in this derivation assumes which radius is larger: \(s\) is simply positive, negative, or zero, and \(\varphi\), \(t\), \(\mathbf{T}_1\), \(\mathbf{T}_2\), \(\mathbf{T}_1'\), \(\mathbf{T}_2'\) come out right in every case, including two equal-sized wheels (\(s=0\Rightarrow\varphi=0\)).

Total Chain Length

Both wheels share the very same pair of absolute tangent-point angles, \(\theta+\tfrac12\pi+\varphi\) and \(\theta+\tfrac32\pi-\varphi\), because both tangent lines rotate each radius by the same amount. Going counter-clockwise between them sweeps an angle of \((\theta+\tfrac32\pi-\varphi)-(\theta+\tfrac12\pi+\varphi)=\pi-2\varphi\), centered exactly on the world-angle \(\theta+\pi\).

Seen from \(\mathbf{M}_1\), \(\theta+\pi\) points directly away from \(\mathbf{M}_2\), so that \(\pi-2\varphi\) sweep is the arc facing away from the other wheel — precisely the arc the chain wraps around. Seen from \(\mathbf{M}_2\), though, \(\theta+\pi\) points directly towards \(\mathbf{M}_1\), so the very same sweep now sits on the side facing the other wheel, i.e. inside the gap the chain leaves open. The chain instead wraps the complementary arc there, of size \(2\pi-(\pi-2\varphi)=\pi+2\varphi\). This gives the two wrap angles and their arc lengths:

\[a_1=\pi-2\varphi,\qquad a_2=\pi+2\varphi,\qquad l_1=r_1a_1,\qquad l_2=r_2a_2.\]

Together with the two tangent segments of length \(t\) each, the total chain length is

\[l=l_1+l_2+2t.\]

Placing the Chain Links

For \(n\) links of equal length \(\overline{l}=l/n\), unrolling the chain onto a straight line splits it into the same four pieces in order: the arc \(l_2\) around \(C_2\), the tangent segment \(t\) from \(\mathbf{T}_2'\) to \(\mathbf{T}_1'\), the arc \(l_1\) around \(C_1\), and the remaining tangent segment \(t\) from \(\mathbf{T}_1\) back to \(\mathbf{T}_2\):

Given the position \(c:=k\cdot\overline{l}+z \pmod l\) of link \(k\) along the unrolled chain — \(z\) is a free offset used to scroll all links along the loop for the animation — the link's actual point \(\mathbf{N}_k\) on the loop depends on which of the four segments \(c\) falls into:

On the arc around \(C_2\) (\(0\le c<l_2\)): with \(p:=c/l_2\), \[\mathbf{N}_k=\mathbf{M}_2+r_2\operatorname{Rot}\big(\theta+\tfrac12\pi+\varphi-p\,a_2\big).\]

On the tangent segment \(\mathbf{T}_2'\to\mathbf{T}_1'\) (\(l_2\le c<l_2+t\)): with \(p:=(c-l_2)/t\), \[\mathbf{N}_k=\mathbf{T}_2'+t\,p\operatorname{Rot}(\pi-\varphi+\theta).\]

On the arc around \(C_1\) (\(l_2+t\le c<l_2+t+l_1\)): with \(p:=(c-l_2-t)/l_1\), \[\mathbf{N}_k=\mathbf{M}_1+r_1\operatorname{Rot}\big(\theta+\tfrac32\pi-\varphi-p\,a_1\big).\]

On the tangent segment \(\mathbf{T}_1\to\mathbf{T}_2\) (\(l_2+t+l_1\le c<l\)): with \(p:=(c-l_2-t-l_1)/t\), \[\mathbf{N}_k=\mathbf{T}_1+t\,p\operatorname{Rot}(\varphi+\theta).\]

Advancing \(z\) frame by frame and recomputing every \(\mathbf{N}_k\) is all the animation above does; because it re-derives \(\theta\), \(\varphi\), \(t\), \(l_1\), \(l_2\) from \(\mathbf{M}_1,r_1,\mathbf{M}_2,r_2\) on every frame, it keeps working unchanged no matter how the two wheels are dragged or resized.