1 THE GAUSS INTEGRAL FOR THE LINKING NUMBER OF DISJOINT CURVES

This extended version of the conference paper [8] includes all previously skipped proofs. For any vectors \({\mathbf{u}},{\mathbf{v}},{\mathbf{w}} \in {{\mathbb{R}}^{3}}\), the triple product is \(({\mathbf{u}},{\mathbf{v}},{\mathbf{w}}) = ({\mathbf{u}} \times {\mathbf{v)}} \cdot {\mathbf{w}}\).

Definition 1 (Gauss integral for the linking number). For piecewise-smooth curves \({{\gamma }_{1}},{{\gamma }_{2}}:[0,\;1] \to {{\mathbb{R}}^{3}}\), the linking number can be defined as the Gauss integral [13]

$$\operatorname{lk} ({{\gamma }_{1}},{{\gamma }_{2}}) = \frac{1}{{4\pi }}\int\limits_0^1 {\int\limits_0^1 {\frac{{({{{\dot {\gamma }}}_{1}}(t),{{{\dot {\gamma }}}_{2}}(s),{{\gamma }_{1}}(t) - {{\gamma }_{2}}(s))}}{{|{\kern 1pt} {{\gamma }_{1}}(t) - {{\gamma }_{2}}(s){\kern 1pt} {{|}^{3}}}}dtds} } ,$$
(1)

where \({{\dot {\gamma }}_{1}}(t)\), \({{\dot {\gamma }}_{2}}(s)\) are the vector derivatives of the 1-variable functions \({{\gamma }_{1}}(t)\), \({{\gamma }_{2}}(s)\).

The formula in Definition 1 gives an integer number for any closed disjoint curves \({{\gamma }_{1}}\), \({{\gamma }_{2}}\) due to its interpretation as the degree of the Gauss map \(\Gamma (t,s) = \frac{{{{\gamma }_{1}}(t) - {{\gamma }_{2}}(s)}}{{\left| {{{\gamma }_{1}}(t) - {{\gamma }_{2}}(s)} \right|}}:{{S}^{1}} \times {{S}^{1}} \to {{S}^{2}}\), i.e. \(\deg \Gamma = \frac{{\operatorname{area} (\Gamma ({{S}^{1}} \times {{S}^{1}}))}}{{\operatorname{area} ({{S}^{2}})}}\), where the area of the unit sphere is \({\text{area}}({{S}^{2}}) = 4\pi \). This integer degree is the linking number of the 2-component link \({{\gamma }_{1}} \sqcup {{\gamma }_{2}} \subset {{\mathbb{R}}^{3}}\) formed by the two closed curves. Invariance modulo continuous deformation of \({{\mathbb{R}}^{3}}\) follows easily for closed curves; indeed, the function under the Gauss integral in (1), and hence the integral itself, varies continuously under perturbations of the curves \({{\gamma }_{1}}\), \({{\gamma }_{2}}\). This should keep any integer value constant.

For open curves \({{\gamma }_{1}}\), \({{\gamma }_{2}}\), the Gauss integral gives a real but not necessarily integral value, which remains invariant under rigid motions or orientation-preserving isometries (see Theorem 1). In \({{\mathbb{R}}^{3}}\) with the Euclidean metric isometries consist of rotations, translations and reflections. Isometry invariance of the real-valued linking number for open curves has found applications in the study of molecules [1].

Any smooth curve can be well-approximated by a polygonal line, so the computation of the linking number reduces to a sum over pairs of straight line segments \({{L}_{1}}\), \({{L}_{2}}\). In 1976 Banchoff [5] has expressed the linking number \({\text{lk}}({{L}_{1}},{{L}_{2}})\) in terms of the endpoints of each segment, see details of this and other past work in Section 3.

In 2000 Klenin and Langowski [14] proposed a formula for the linking number \({\text{lk}}({{L}_{1}},{{L}_{2}})\) of two straight line segments in terms of six isometry invariants of \({{L}_{1}}\), \({{L}_{2}}\), referring to a previous paper [25], which used the formula without any detailed proof. The paper [14] also skipped all details of the invariant-based formula’s derivation.

The usefulness of the invariant-based formula can be seen by considering the analogy with the simpler concept of the scalar (dot) product of vectors. The algebraic or coordinate-based formula expresses the scalar product of two vectors \(\mathbf{u} = ({{x}_{1}},{{y}_{1}},{{z}_{1}})\) and \(\mathbf{v} = ({{x}_{2}},{{y}_{2}},{{z}_{2}})\) as \(\mathbf{u}\cdot \mathbf{v} = {{x}_{1}}{{x}_{2}} + {{y}_{1}}{{y}_{2}} + {{z}_{1}}{{z}_{2}}\), which in turn depend on the co-ordinates of their endpoints. However, the scalar product for high-dimensional vectors \(\mathbf{u},\mathbf{v} \in {{\mathbb{R}}^{n}}\) can also expressed in terms of only 3 parameters \(\mathbf{u}\cdot \mathbf{v} = \left| \mathbf{u} \right| \cdot \left| \mathbf{v} \right|\cos \angle {\kern 1pt} \left( {\left| \mathbf{u} \right|,\mathbf{v}} \right)\). The two lengths \(\left| \mathbf{u} \right|\), \(\left| \mathbf{v} \right|\) and the angle \(\angle (\mathbf{u},\mathbf{v})\) are isometry invariants of the vectors \(\mathbf{u}\), \(\mathbf{v}\). This second geometric or invariant-based formula makes it clear that \(\mathbf{u}\cdot \mathbf{v}\) is an isometry invariant, while it is harder to show that \(\mathbf{u}\cdot \mathbf{v} = {{x}_{1}}{{x}_{2}} + {{y}_{1}}{{y}_{2}} + {{z}_{1}}{{z}_{2}}\) is invariant under rotations. It also provides other geometric insights that are hard to extract from the coordinate-based formula; for example, \(\mathbf{u}\cdot \mathbf{v}\) oscillates as a cosine wave when the lengths \(\left| \mathbf{u} \right|\), \(\left| \mathbf{v} \right|\) are fixed, but the angle \(\angle (\mathbf{u},\mathbf{v})\) is varying.

In this paper, we provide a detailed proof of the invariant-based formula for the linking number in T-heorem 2 and new corollaries in Section 6 formally investigating the asymptotic behaviour of the linking number, which wasn’t previously studied.

Our own interest in the asymptotic behaviour is motivated by the periodic linking number by Panagiotou [20] as an invariant of crystalline networks [11] that are infinitely periodic in three directions, by calculating the infinite sum of the linking number between one line segment and all translated copies of another such segment.

2 OUTLINE OF THE INVARIANT-BASED FORMULA AND CONSEQUENCES

Folklore Theorem 1 lists key properties of \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}})\), which will be used later.

Theorem 1 (properties of the linking number). The linking number defined by the Gauss integral in Definition 1 for smooth curves \({{\gamma }_{1}}\), \({{\gamma }_{2}}\) has the following properties:

(2a) the linking number is symmetric: \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}}) = {\text{lk}}({{\gamma }_{2}},{{\gamma }_{1}})\);

(2b) \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}}) = 0\) for any curves \({{\gamma }_{1}}\), \({{\gamma }_{2}}\) that belong to the same plane;

(2c) \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}})\) is independent of orientation-preserving parameterizations of the open curves \({{\gamma }_{1}}\), \({{\gamma }_{2}}\) with fixed endpoints;

(2d) \({\text{lk}}( - {{\gamma }_{1}},{{\gamma }_{2}}) = - {\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}})\), where \( - {{\gamma }_{1}}\) has the reversed orientation of \({{\gamma }_{1}}\);

(2e) the linking number \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}})\) is invariant under any scaling \({\mathbf{v}} \to \lambda {\mathbf{v}}\) for \(\lambda > 0\);

(2f) \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}})\) is multiplied by \(\det M\) under any orthogonal map \({\mathbf{v}} \mapsto M{\mathbf{v}}\).

Proof. (2a) We note that the Euclidean distance is symmetric, and that since the triple product is anti-symmetric and \({{\gamma }_{2}}(s) - {{\gamma }_{1}}(t) = - ({{\gamma }_{1}}(t) - {{\gamma }_{2}}(s))\), the symmetry follows from

$$\begin{gathered} ({{{\dot {\gamma }}}_{2}}(s),{{{\dot {\gamma }}}_{1}}(t),{{\gamma }_{2}}(s) - {{\gamma }_{1}}(t)) = - ({{{\dot {\gamma }}}_{1}}(t),{{{\dot {\gamma }}}_{2}}(s),{{\gamma }_{2}}(s) - {{\gamma }_{1}}(t)) \\ = - ({{{\dot {\gamma }}}_{1}}(t),{{{\dot {\gamma }}}_{2}}(s), - ({{\gamma }_{1}}(t) - {{\gamma }_{2}}(s))) = ({{{\dot {\gamma }}}_{1}}(t),{{{\dot {\gamma }}}_{2}}(s),{{\gamma }_{1}}(t) - {{\gamma }_{2}}(s)). \\ \end{gathered} $$

(2b) is obvious from the coplanarity of the normal vectors.

(2c) is simply a consequence of the path-independence of the integrals over \(s,\;t\).

(2d) follows from \({{\dot {\gamma }}_{1}}(1 - t) = - \dot {\gamma }(t)\) since the reverse orientation of \({{\gamma }_{1}}(t)\) is \({{\gamma }_{1}}(1 - t)\).

(2e) Any scaling \(\mathbf{v} \mapsto \lambda \mathbf{v}\) will result in a change of parameterization \({{\gamma }_{i}}(t) \mapsto \lambda {{\gamma }_{i}}(t)\). Since \(\dot {\lambda }{{\gamma }_{i}}(t) = \lambda {{\dot {\gamma }}_{i}}(t)\), the result follows below

$$\begin{gathered} {\text{lk}}(\lambda {{\gamma }_{1}}(t),\lambda {{\gamma }_{2}}(s)) = \frac{1}{{4\pi }}\int\limits_0^1 {\int\limits_0^1 {\frac{{(\lambda {{{\dot {\gamma }}}_{1}}(t),\lambda {{{\dot {\gamma }}}_{2}}(s),\lambda ({{\gamma }_{1}}(t) - {{\gamma }_{2}}(s)))}}{{{{{\left| {\lambda ({{\gamma }_{1}}(t) - {{\gamma }_{2}}(s))} \right|}}^{3}}}}dtds} } \\ = \;\frac{1}{{4\pi }}\int\limits_0^1 {\int\limits_0^1 {\frac{{{{\lambda }^{3}}({{{\dot {\gamma }}}_{1}}(t),{{{\dot {\gamma }}}_{2}}(s),{{\gamma }_{1}}(t) - {{\gamma }_{2}}(s))}}{{{{\lambda }^{3}}{{{\left| {{{\gamma }_{1}}(t) - {{\gamma }_{2}}(s)} \right|}}^{3}}}}dtds} } = {\text{lk}}({{\gamma }_{1}}(t),{{\gamma }_{2}}(s)). \\ \end{gathered} $$

(2f) For an orthogonal transformation \(M\), we have \(M\mathbf{u} \times M\mathbf{v} = (\det M)M(\mathbf{u} \times \mathbf{v})\), while \(M\mathbf{u} \cdot M\mathbf{v} = \mathbf{u}\cdot \mathbf{v}\). Therefore \(\left| {M\mathbf{v} - M\mathbf{u}} \right| = \left| {\mathbf{v} - \mathbf{u}} \right|\), \((M\mathbf{u},M\mathbf{v},M\mathbf{w}) = \det M(\mathbf{u},\mathbf{v},\mathbf{w})\) and \({\text{lk}}(M{{\gamma }_{1}},M{{\gamma }_{2}}) = (\det M)({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}}))\) \({\text{lk}}(M{{\gamma }_{1}},M{{\gamma }_{2}}) = (\det M)({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}}))\) as expected.

Our main Theorem 2 will prove an analytic formula for the linking number of any line segments \({{L}_{1}}\), \({{L}_{2}}\) in terms of 6 isometry invariants of \({{L}_{1}}\), \({{L}_{2}}\), which are introduced in Lemma 1. Simpler Corollary 1 expresses \({\text{lk}}({{L}_{1}},{{L}_{2}})\) for any simple orthogonal oriented segments \({{L}_{1}}\), \({{L}_{2}}\) defined by their lengths \({{l}_{1}},{{l}_{2}} > 0\) and initial endpoints \({{O}_{1}}\), \({{O}_{2}}\), respectively, with the Euclidean distance \(d({{O}_{1}},{{O}_{2}}) = d > 0\), so that \({{{\mathbf{L}}}_{1}}\), \({{{\mathbf{L}}}_{2}}\), \(\overrightarrow {{{O}_{1}}{{O}_{2}}} \) form a positively oriented orthogonal basis whose signed volume \(\left| {\left( {{{{\mathbf{L}}}_{1}},{{{\mathbf{L}}}_{2}},\overrightarrow {{{O}_{1}}{{O}_{2}}} } \right)} \right| = {{l}_{1}}{{l}_{2}}d\) is the product of the lengths, see the first picture in Fig. 1.

Fig. 1.
figure 1

Each line segment \({{L}_{i}}\) is in the plane \(\{ z = ( - {{1)}^{i}}d{\text{/}}2\} \), \(i = 1,\;2\). Left: signed distance \(d > 0\), the endpoint coordinates \({{a}_{1}} = 0\), \({{b}_{1}} = 1\) and \({{a}_{2}} = 0\), \({{b}_{2}} = 1\), the lengths \({{l}_{1}} = {{l}_{2}} = 1\). Right: signed distance \(d < 0\), the endpoint coordinates \({{a}_{1}} = - 1\), \({{b}_{1}} = 1\) and \({{a}_{2}} = - 1\), \({{b}_{2}} = 1\), so \({{l}_{1}} = {{l}_{2}} = 2\). In both middle pictures \(\alpha = \pi {\text{/}}2\) is the angle from \({\text{p}}{{{\text{r}}}_{{xy}}}({{L}_{1}})\) to \({\text{p}}{{{\text{r}}}_{{xy}}}({{L}_{2}})\) with \(x\)-axis as the bisector.

Corollary 1 (linking number for simple orthogonal segments). For any simple orthogonal oriented line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) with lengths \({{l}_{1}},{{l}_{2}}\) and a distance \(d\) as defined above, the linking number is \({\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\arctan \left( {\frac{{{{l}_{1}}{{l}_{2}}}}{{d\sqrt {l_{1}^{2} + l_{2}^{2} + {{d}^{2}}} }}} \right)\).

The above expression is a special case of general formula (3) for \({{a}_{1}} = {{a}_{2}} = 0\) and \(\alpha = \pi {\text{/}}2\). Both formulas are invariant under the uniform scaling of \({{\mathbb{R}}^{3}}\) by \(\lambda \), which agrees with Theorem 1. If \({{l}_{1}} = {{l}_{2}} = l\), the linking number in Corollary 1 becomes \({\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\arctan \frac{{{{l}^{2}}}}{{d\sqrt {2{{l}^{2}} + {{d}^{2}}} }}\). If \({{l}_{1}} = {{l}_{2}} = d{\text{/}}2\), then \({\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{1}{{2\pi }}\left( {\arcsin \frac{1}{{\sqrt {2.5} }} - \frac{\pi }{4}} \right) \approx - 0.016\). If \({{l}_{1}} = {{l}_{2}} = d\), then \({\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\arctan \frac{1}{{\sqrt 3 }} = - \frac{1}{{24}} \approx - 0.0417\) \({\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\arctan \frac{1}{{\sqrt 3 }} = - \frac{1}{{24}} \approx - 0.0417\).

Corollary 1 implies that the linking number is in the range \(( - 1{\text{/}}8,\;0)\) for any simple orthogonal segments with \(d > 0\), which wasn’t obvious from Definition 1. If \({{L}_{1}}\), \({{L}_{2}}\) move away from each other, then \(\mathop {\lim }\limits_{d \to + \infty } {\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\arctan 0 = 0\).

Alternatively, if segments with \({{l}_{1}} = {{l}_{2}} = l\) become infinitely short, the limit is again zero: \(\mathop {\lim }\limits_{l \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) for any fixed \(d\). The limit \(\mathop {\lim }\limits_{x \to + \infty } \arctan x = \frac{\pi }{2}\) implies that if segments with \({{l}_{1}} = {{l}_{2}} = l\) become infinitely long for a fixed distance \(d\), \(\mathop {\lim }\limits_{l \to + \infty } {\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\arctan \frac{{{{l}^{2}}}}{{d\sqrt {2{{l}^{2}} + {{d}^{2}}} }} = - \frac{1}{8}\). If we push the segments \({{L}_{1}}\), \({{L}_{2}}\), which have fixed (possibly different) lengths \({{l}_{1}}\), \({{l}_{2}}\) towards each other, the same limit similarly emerges: \(\mathop {\lim }\limits_{d \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{8}\). See more general corollaries in Section 6.

3 PAST RESULTS ABOUT THE GAUSS INTEGRAL FOR THE LINKING NUMBER

The survey [22] reviews the history of the Gauss integral, its use in Maxwell’s description of electromagnetic fields [18], and its interpretation as the degree of a map from the torus to the sphere. In classical knot theory \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}})\) is a topological invariant of a link consisting of closed curves \({{\gamma }_{1}} \sqcup {{\gamma }_{2}}\), whose equivalence relation is ambient isotopy. This relation is too flexible for open curves which can be isotopically unwound, and hence doesn’t preserve the Gauss integral for open curves \({{\gamma }_{1}}\), \({{\gamma }_{2}}\).

Computing the value of the Gauss integral directly from the parametric equation of two generic curves is only possible by approximation, but this problem is simplified when we consider straight lines. The first form of the linking number between two straight line segments in terms of their geometry is described by Banchoff [5]. Banchoff considers the projection of segments on to a plane orthogonal to some vector \(\xi \in {{S}^{2}}\). The Gauss integral is interpreted as the fraction of the unit sphere covered by those directions of \(\xi \) for which the projection will have a crossing.

This interpretation was the foundation of a closed form developed by Arai [4], using van Oosterom and Strackee’s closed formula for the solid angle subtended by a tetrahedron given by the origin of a sphere and three points on its surface. An efficient implementation of the solid angle approach to the linking number is discussed in [6].

An alternative calculation for this solid angle is given in [21] as a starting point for calculating further invariants of open entangled curves. This form does not employ geometric invariants, but was used in [14] to claim a formula (without a proof) similar to Theorem 2, which is proved in this paper with more corollaries in Section 6.

4 SIX ISOMETRY INVARIANTS OF SKEW LINE SEGMENTS IN 3-SPACE

This section introduces six isometry invariants, which uniquely determine positions of any line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) modulo isometries of \({{\mathbb{R}}^{3}}\), see Lemma 1.

It suffices to consider only skew line segments that do not belong to the same 2-dimensional plane. If \({{L}_{1}}\), \({{L}_{2}}\) are in the same plane \(\Pi \), for example if they are parallel, then \({{\dot {L}}_{1}}(t) \times {{\dot {L}}_{2}}(s)\) is orthogonal to any vector \({{L}_{1}}(t) - {{L}_{2}}(s)\) in the plane \(\Pi \), hence \({\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\). We denote by \({{\bar {L}}_{1}},{{\bar {L}}_{2}} \subset {{\mathbb{R}}^{3}}\) the infinite oriented lines through the given line segments \({{L}_{1}}\), \({{L}_{2}}\), respectively. In a plane with fixed coordinates \(x\), \(y\), all angles are measured anticlockwise from the positive \(x\)-axis.

Definition 2 (invariants of line segments). Let \(\alpha \in [0,\pi ]\) be the angle between oriented line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\). Assuming that \({{L}_{1}}\), \({{L}_{2}}\) are not parallel, there is a unique pair of parallel planes \({{\Pi }_{i}}\), \(i = 1,\;2\), each containing the infinite line \({{\bar {L}}_{i}}\) through the line segment \({{L}_{i}}\). We choose orthogonal coordinates \(x\), \(y\), \(z\) in \({{\mathbb{R}}^{3}}\) so that

(4a) the horizontal plane \(\{ z = 0\} \) is in the middle between \({{\Pi }_{1}},{{\Pi }_{2}}\), see Fig. 1;

(4b) \((0,0,0)\) is the intersection of the projections \({\text{p}}{{{\text{r}}}_{{xy}}}({{\bar {L}}_{1}}),{\text{p}}{{{\text{r}}}_{{xy}}}({{\bar {L}}_{2}})\) to \(\{ z = 0\} \);

(4c) the \(x\)-axis bisects the angle \(\alpha \) from \({\text{p}}{{{\text{r}}}_{{xy}}}({{\bar {L}}_{1}})\) to \({\text{p}}{{{\text{r}}}_{{xy}}}({{\bar {L}}_{2}})\), the \(y\)-axis is chosen so that \(\alpha \) is anticlockwisely measured from the \(x\)-axis to the \(y\)-axis in \(\{ z = 0\} \);

(4d) the \(z\)-axis is chosen so that \(x\), \(y\), \(z\) are oriented in the right hand way, then \(d\) is the signed distance from \({{\Pi }_{1}}\) to \({{\Pi }_{2}}\); the distance \(d\) is negative if the vector \(\overrightarrow {{{O}_{1}}{{O}_{2}}} \) is opposite to the positively oriented \(z\)-axis in Fig. 1.

Let \({{a}_{i}}\), \({{b}_{i}}\) be the coordinates of the initial and final endpoints of the segments \({{L}_{i}}\) in the infinite line \({{\bar {L}}_{i}}\) whose origin is \({{O}_{i}} = {{\Pi }_{i}} \cap (z{\text{-axis}}) = (0,\;0,\;{{( - 1)}^{i}}d{\text{/}}2)\), \(i = 1,\;2\).

The case of segments \({{L}_{1}},{{L}_{2}}\) lying in the same plane \(\Pi \subset {{\mathbb{R}}^{3}}\) can be formally covered by Definition 2 if we allow the signed distance \(d\) from \({{\Pi }_{1}}\) to \({{\Pi }_{2}}\) to be 0.

Lemma 1 (parameterization). Any oriented line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) are uniquely determined modulo a rigid motion by their isometry invariants \(\alpha \in [0,\pi ]\) and \(d\), \({{a}_{1}}\), \({{b}_{1}}\), \({{a}_{2}}\), \({{b}_{2}} \in \mathbb{R}\) from Definition 2. For \({{l}_{i}} = {{b}_{i}} - {{a}_{i}}\), \(i = 1,\;2\), each line segment \({{L}_{i}}\) is

$${{L}_{i}}(t) = \left( {\left( {{{a}_{i}} + {{l}_{i}}t} \right)\cos \frac{\alpha }{2},\;{{{( - 1)}}^{i}}\left( {{{a}_{i}} + {{l}_{i}}t} \right)\sin \frac{\alpha }{2},\;{{{( - 1)}}^{i}}\frac{d}{2}} \right),\quad t \in [0,\;1].$$
(2)

Proof. Any line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) that are not in the same plane are contained in distinct parallel planes. For \(i = 1,\;2\), the plane \({{\Pi }_{i}}\) is spanned by \({{L}_{i}}\) and the line parallel to \({{L}_{{3 - i}}}\) and passing through an endpoint of \({{L}_{i}}\). Let \(L_{i}^{'}\) be the orthogonal projection of the line segment \({{L}_{i}}\) to the plane \({{\Pi }_{{3 - i}}}\). The non-parallel lines through the segments \({{L}_{i}}\) and \(L_{{3 - i}}^{'}\) in the plane \({{\Pi }_{i}}\) intersect at a point, say \({{O}_{i}}\). Then the line segment \({{O}_{1}}{{O}_{2}}\) is orthogonal to both planes \({{\Pi }_{i}}\), hence to both \({{L}_{i}}\) for \(i = 1,\;2\).

By Theorem 1, to compute \({\text{lk}}({{L}_{1}},{{L}_{2}})\), one can apply a rigid motion to move the mid-point of the line segment \({{O}_{1}}{{O}_{2}}\) to the origin \(O = (0,0,0) \in {{\mathbb{R}}^{2}}\) and make \({{O}_{1}}{{O}_{2}}\) vertical, i.e. lying within the \(z\)-axis. The signed distance \(d\) can be defined as the difference between the coordinates of \({{O}_{2}} = {{\Pi }_{2}} \cap (z{\text{-axis}})\) and \({{O}_{1}} = {{\Pi }_{1}} \cap (z{\text{-axis}})\) along the \(z\)-axis. Then \({{L}_{i}}\) lies in the horizontal plane \({{\Pi }_{i}} = \{ z = ( - {{1)}^{i}}d{\text{/}}2\} \), \(i = 1,\;2\).

An extra rotation around the \(z\)-axis guarantees that the \(x\)-axis in the horizontal plane \(\Pi = \{ z = 0\} \) is the bisector of the angle \(\alpha \in [0,\pi ]\) from \({\text{p}}{{{\text{r}}}_{{xy}}}({{\bar {L}}_{1}})\) to \({\text{p}}{{{\text{r}}}_{{xy}}}({{\bar {L}}_{2}})\), where \({\text{p}}{{{\text{r}}}_{{xy}}}:{{\mathbb{R}}^{3}} \to \Pi \) is the orthogonal projection. Then the infinite lines \({{\bar {L}}_{i}}\) through \({{L}_{i}}\) have the parametric form (x, y, z) = \((t\cos (\alpha {\text{/}}2),( - {{1)}^{i}}t\sin (\alpha {\text{/}}2),( - {{1)}^{i}}d{\text{/}}2)\) with \(s \in \mathbb{R}\).

The point \({{O}_{i}}\) can be considered as the origin of the oriented infinite line \({{\bar {L}}_{i}}\). Let the line segment \({{L}_{i}}\) have a length \({{l}_{i}} > 0\) and its initial point have the coordinate \({{a}_{i}} \in \mathbb{R}\) in the oriented line \({{\bar {L}}_{i}}\). Then the final endpoint of \({{L}_{i}}\) has the coordinate \({{b}_{i}} = {{a}_{i}} + {{l}_{i}}\). To cover only the segment \({{L}_{i}}\), the parameter \(t\) should be replaced by \({{a}_{i}} + {{l}_{i}}t\), \(t \in [0,1]\).

If \(t \in \mathbb{R}\) in Lemma 1, the corresponding point \({{L}_{i}}(t)\) moves along the line \({{\bar {L}}_{i}}\).

Lemma 2 (formulas for invariants). Let \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) be any skewed oriented line segments given by their initial and final endpoints \({{A}_{i}},{{B}_{i}} \in {{\mathbb{R}}^{3}}\) so that \({\mathbf{L}_{i}} = \overrightarrow {{{A}_{i}}{{B}_{i}}} \), \(i = 1,\;2\). Then the isometry invariants of \({{L}_{1}}\), \({{L}_{2}}\) in Lemma 1 are computed as follows:

the lengths \({{l}_{i}} = {\text{|}}\overrightarrow {{{A}_{i}}{{B}_{i}}} {\text{|}}\), the signed distance \(d = \frac{{\left[ {{\mathbf{L}_{1}},{\mathbf{L}_{2}},\overrightarrow {{{A}_{1}}{{A}_{2}}} } \right]}}{{\left| {{\mathbf{L}_{1}} \times {\mathbf{L}_{2}}} \right|}}\), the angle \(\alpha = \arccos \frac{{{\mathbf{L}_{1}} \cdot {\mathbf{L}_{2}}}}{{{{l}_{1}}{{l}_{2}}}}\), \({{a}_{1}} = \left( {\frac{{{\mathbf{L}_{2}}}}{{{{l}_{2}}}}\cos \alpha - \frac{{{\mathbf{L}_{1}}}}{{{{l}_{1}}}}} \right) \cdot \frac{{\overrightarrow {{{A}_{1}}{{A}_{2}}} }}{{{{{\sin }}^{2}}\alpha }}\), \({{a}_{2}} = \left( {\frac{{{\mathbf{L}_{2}}}}{{{{l}_{2}}}} - \frac{{{\mathbf{L}_{1}}}}{{{{l}_{1}}}}\cos \alpha } \right) \cdot \frac{{\overrightarrow {{{A}_{1}}{{A}_{2}}} }}{{{{{\sin }}^{2}}\alpha }}\), \(\;{{b}_{i}} = {{a}_{i}} + {{l}_{i}}\), \(i = 1,2\).

Proof. The vectors along the segments are \({\mathbf{L}_{i}}\), hence the lengths are \({{l}_{i}} = \left| {{\mathbf{L}_{i}}} \right| = \left| {\overrightarrow {{{A}_{i}}{{B}_{i}}} } \right|\), \(i = 1,\;2\). The angle \(\alpha \in [0,\pi ]\) between \({\mathbf{L}_{1}}\), \({\mathbf{L}_{2}}\) can be found from the scalar product \({\mathbf{L}_{1}} \cdot {\mathbf{L}_{2}} = \left| {{\mathbf{L}_{1}}} \right| \cdot \left| {{\mathbf{L}_{2}}} \right|\cos \alpha \) as \(\alpha = \arccos \frac{{{\mathbf{L}_{1}} \cdot {\mathbf{L}_{2}}}}{{{{l}_{1}}{{l}_{2}}}}\), because the function \(\arccos x:[ - 1,1] \to [0,\pi ]\) is bijective. Since the vectors \({\mathbf{L}_{1}}\), \({\mathbf{L}_{2}}\) are not proportional to each other, the normalized vector product \({{{\mathbf{e}}}_{3}} = \frac{{{\mathbf{L}_{1}} \times {\mathbf{L}_{2}}}}{{\left| {{\mathbf{L}_{1}} \times {\mathbf{L}_{2}}} \right|}}\) is well-defined and orthogonal to both \({\mathbf{L}_{1}}\), \({\mathbf{L}_{2}}\). Then \({\mathbf{e}_{1}} = \frac{{{\mathbf{L}_{1}}}}{{\left| {{\mathbf{L}_{1}}} \right|}}\), \({\mathbf{e}_{2}} = \frac{{{\mathbf{L}_{2}}}}{{\left| {{\mathbf{L}_{2}}} \right|}}\) and \({\mathbf{e}_{3}}\) have lengths 1 and form a linear basis of \({{\mathbb{R}}^{3}}\), where the last vector is orthogonal to the first two.

Let \(O\) be any fixed point of \({{\mathbb{R}}^{3}}\), which can be assumed to be the origin \((0,0,0)\) in the coordinates of Lemma 1, though its position relative to the vectors \(\overrightarrow {{{A}_{i}}{{B}_{i}}} \) is not yet determined. First we express the points \({{O}_{i}} = (0,0,( - {{1)}^{i}}d{\text{/}}2) \in {{\bar {L}}_{i}}\) from Fig. 3 in terms of given vectors \(\overrightarrow {{{A}_{i}}{{B}_{i}}} \). If the initial endpoint \({{A}_{i}}\) has a coordinate \({{a}_{i}}\) in the line \({{\bar {L}}_{i}}\) through the line segment \({{L}_{i}}\), then \(\overrightarrow {{{O}_{i}}{{A}_{i}}} = {{a}_{i}}{\mathbf{e}_{i}}\) and

$$\overrightarrow {{{O}_{1}}{{O}_{2}}} = \overrightarrow {O{{O}_{2}}} - \overrightarrow {O{{O}_{1}}} = \left( {\overrightarrow {O{{A}_{2}}} - \overrightarrow {{{O}_{2}}{{A}_{2}}} } \right) - \left( {\overrightarrow {O{{A}_{1}}} - \overrightarrow {{{O}_{1}}{{A}_{1}}} } \right) = \overrightarrow {{{A}_{1}}{{A}_{2}}} + {{a}_{1}}{\mathbf{e}_{1}} - {{a}_{2}}{\mathbf{e}_{2}}.$$

By Definition 2, \(\overrightarrow {{{O}_{1}}{{O}_{2}}} \) is orthogonal to the line \({{\bar {L}}_{i}}\) going through the vector \({\mathbf{e}_{i}} = \frac{{{\mathbf{L}_{i}}}}{{\left| {{\mathbf{L}_{i}}} \right|}}\) for \(i = 1,\;2\). Then the product \([{\mathbf{e}_{1}},{\mathbf{e}_{2}},\overrightarrow {{{O}_{1}}{{O}_{2}}} ] = ({\mathbf{e}_{1}} \times {\mathbf{e}_{2}}) \cdot \overrightarrow {{{O}_{1}}{{O}_{2}}} \) equals \(\left| {{\mathbf{e}_{1}} \times {\mathbf{e}_{2}}} \right|d\), where \(\overrightarrow {{{O}_{1}}{{O}_{2}}} \) is in the \(z\)-axis, the signed distance \(d\) is the \(z\)-coordinate of \({{O}_{2}}\) minus the \(z\)-coordinate of \({{O}_{1}}\). The triple product \(\left[ {{\mathbf{e}_{1}},{\mathbf{e}_{2}},\overrightarrow {{{O}_{1}}{{O}_{2}}} } \right] = ({\mathbf{e}_{1}} \times {\mathbf{e}_{2}}) \cdot \left( {\overrightarrow {{{A}_{1}}{{A}_{2}}} + {{a}_{1}}{\mathbf{e}_{1}} - {{a}_{2}}{\mathbf{e}_{2}}} \right) = ({\mathbf{e}_{1}} \times {\mathbf{e}_{2}}) \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} \) doesn’t depend on the parameters \({{a}_{1}}\), \({{a}_{2}}\), because \({\mathbf{e}_{1}} \times {\mathbf{e}_{2}}\) is orthogonal to both \({\mathbf{e}_{1}}\), \({\mathbf{e}_{2}}\). Hence the signed distance is \(d = \frac{{[{\mathbf{e}_{1}},{\mathbf{e}_{2}},\overrightarrow {{{A}_{1}}{{A}_{2}}} ]}}{{\left| {{\mathbf{e}_{1}} \times {\mathbf{e}_{2}}} \right|}} = \frac{{[{\mathbf{L}_{1}},{\mathbf{L}_{2}},\overrightarrow {{{A}_{1}}{{A}_{2}}} ]}}{{\left| {{\mathbf{L}_{1}} \times {\mathbf{L}_{2}}} \right|}}\), which can be positive or negative, see Fig. 3.

It remains to find the coordinate \({{a}_{i}}\) of the initial endpoint of \({{L}_{i}}\) relative to the origin \({{O}_{i}} \in {{\bar {L}}_{i}}\), \(i = 1,\;2\). The vector \(\overrightarrow {{{O}_{1}}{{O}_{2}}} = \overrightarrow {{{A}_{1}}{{A}_{2}}} + {{a}_{1}}{\mathbf{e}_{1}} - {{a}_{2}}{\mathbf{e}_{2}}\) is orthogonal to both \({\mathbf{e}_{i}}\) if and only if the scalar products vanish: \(\overrightarrow {{{O}_{1}}{{O}_{2}}} \cdot {\mathbf{e}_{i}} = 0\). Due to \(\left| {{\mathbf{e}_{1}}} \right| = 1 = \left| {{\mathbf{e}_{2}}} \right|\) and \({\mathbf{e}_{1}} \cdot {\mathbf{e}_{2}} = \cos \alpha \), we get

$$\begin{gathered} {\mathbf{e}_{1}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} + {{a}_{1}} - {{a}_{2}}({\mathbf{e}_{1}} \cdot \cdot {\mathbf{e}_{2}}) = 0, \hfill \\ {\mathbf{e}_{2}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} + {{a}_{1}}({\mathbf{e}_{1}} \cdot {\mathbf{e}_{2}}) - {{a}_{2}} = 0, \hfill \\ \left( {\begin{array}{*{20}{c}} 1&{ - \cos \alpha } \\ {\cos \alpha }&{ - 1} \end{array}} \right)\left( {\begin{array}{*{20}{c}} {{{a}_{1}}} \\ {{{a}_{2}}} \end{array}} \right) = - \left( {\begin{array}{*{20}{c}} {{\mathbf{e}_{1}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} } \\ {{\mathbf{e}_{2}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} } \end{array}} \right). \hfill \\ \end{gathered} $$

The determinant of the \(2 \times 2\) matrix is \({{\cos }^{2}}\alpha - 1 = - {{\sin }^{2}}\alpha \ne 0\), because \({{L}_{1}}\), \({{L}_{2}}\) are not parallel. Then

$$\left( {\begin{array}{*{20}{c}} {{{a}_{1}}} \\ {{{a}_{2}}} \end{array}} \right) = \frac{1}{{{{{\sin }}^{2}}\alpha }}\left( {\begin{array}{*{20}{c}} { - 1}&{\cos \alpha } \\ { - \cos \alpha }&1 \end{array}} \right)\left( {\begin{array}{*{20}{c}} {{\mathbf{e}_{1}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} } \\ {{\mathbf{e}_{2}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} } \end{array}} \right).$$

We get the formulas

$${{a}_{1}} = \frac{{ - {\mathbf{e}_{1}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} + \cos \alpha \left( {{\mathbf{e}_{2}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} } \right)}}{{{{{\sin }}^{2}}\alpha }} = \frac{{({\mathbf{e}_{2}}\cos \alpha - {\mathbf{e}_{1}}) \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} }}{{{{{\sin }}^{2}}\alpha }} = \left( {\frac{{{\mathbf{L}_{2}}}}{{{{l}_{2}}}}\cos \alpha - \frac{{{\mathbf{L}_{1}}}}{{{{l}_{1}}}}} \right) \cdot \frac{{\overrightarrow {{{A}_{1}}{{A}_{2}}} }}{{{{{\sin }}^{2}}\alpha }},$$
$${{a}_{2}} = \frac{{\cos \alpha \left( {{\mathbf{e}_{1}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} } \right) - {\mathbf{e}_{1}} \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} }}{{{{{\sin }}^{2}}\alpha }} = \frac{{({\mathbf{e}_{2}} - {\mathbf{e}_{1}}\cos \alpha ) \cdot \overrightarrow {{{A}_{1}}{{A}_{2}}} }}{{{{{\sin }}^{2}}\alpha }} = \left( {\frac{{{\mathbf{L}_{2}}}}{{{{l}_{2}}}} - \frac{{{\mathbf{L}_{1}}}}{{{{l}_{1}}}}\cos \alpha } \right) \cdot \frac{{\overrightarrow {{{A}_{1}}{{A}_{2}}} }}{{{{{\sin }}^{2}}\alpha }}.$$

The coordinates of the final endpoints are obtained as \({{b}_{i}} = {{a}_{i}} + {{l}_{i}}\) for \(i = 1,\;2\).

Lemma 3 guarantees that the linking number behaves symmetrically in \(d\), meaning that we may confine any particular analysis to cases where \(d > 0\) or \(d < 0\).

Lemma 3 (symmetry). Let \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) be parameterized as in Lemma 1. Under the central symmetry \({\text{CS}}:(x,y,z) \mapsto ( - x, - y, - z)\) with respect to the origin \((0,0,0) \in {{\mathbb{R}}^{3}}\), the line segments keep their invariants \(\alpha \), \({{a}_{1}}\), \({{b}_{1}}\), \({{a}_{2}}\), \({{b}_{2}}\). The signed distance \(d\) and the linking number change their signs: \({\text{lk}}({\text{CS}}({{L}_{1}}),{\text{CS}}({{L}_{2}})) = - {\text{lk}}({{L}_{1}},{{L}_{2}})\).

Proof. Under the central symmetry \({\text{CS}}\), in the notation of Lemma 2 the vectors \({\mathbf{L}_{1}}\), \({\mathbf{L}_{2}}\), \(\overrightarrow {{{A}_{1}}{{A}_{2}}} \) change their signs. Then the formulas for \(\alpha ,{{a}_{1}},{{b}_{1}},{{a}_{2}},{{b}_{2}}\) gives the same expression, but the triple product \(\left[ {{\mathbf{L}_{1}},{\mathbf{L}_{2}},\overrightarrow {{{A}_{1}}{{A}_{2}}} } \right]\) and \(d\) change their signs.

Since the central symmetry \({\text{CS}}\) is an orthogonal map \(M\) with \(\det M = - 1\), the new linking number changes its sign as follows: \({\text{lk}}({\text{CS}}({{L}_{1}}),{\text{CS}}({{L}_{2}})) = {\text{lk}}({\text{CS}}({{L}_{2}}),{\text{CS}}({{L}_{1}})) = - {\text{lk}}({{L}_{1}},{{L}_{2}})\), where we also make use of the invariance of the linking number under exchange of the segments from Theorem 1(f).

5 INVARIANT-BASED FORMULA FOR THE LINKING NUMBER OF SEGMENTS

This section proves main Theorem 2, which expresses the linking number of two line segments in terms of their six isometry invariants from Definition 2. In 2000 Klenin and Langowski claimed a similar but a bit less symmetric formula [14], but gave no proof, which requires substantial lemmas below. For example, one of their six invariants differs from the signed distance \(d\) between oriented line segments.

Theorem 2 (invariant-based formula). For any line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) with invariants \(\alpha \in (0,\pi )\), \({{a}_{1}},{{b}_{1}},{{a}_{2}},{{b}_{2}},d \in \mathbb{R}\) from Definition 2, we have

$${\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{{{\text{AT}}({{a}_{1}},{{b}_{2}};d,\alpha ) + {\text{AT}}({{b}_{1}},{{a}_{2}};d,\alpha ) - {\text{AT}}({{a}_{1}},{{a}_{2}};d,\alpha ) - {\text{AT}}({{b}_{1}},{{b}_{2}};d,\alpha )}}{{4\pi }},$$
(3)

where

$${\text{AT}}(a,b;d,\alpha ) = \arctan \left( {\frac{{ab\sin \alpha + {{d}^{2}}\cot \alpha }}{{d\sqrt {{{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha + {{d}^{2}}} }}} \right).$$

For \(\alpha = 0\) or \(\alpha = \pi \), we set \({\text{AT}}(a,b;d,\alpha ) = {\text{sign}}(d)\pi {\text{/}}2\). We also set \({\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) when \(d = 0\).

The expression \({{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha \) is the squared third side of the triangle with the first two sides \(a,b\) and the angle \(\alpha \) between them, hence is always non-negative. Also \({{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha = 0\) only when the triangle degenerates for \(a = \pm b\) and \(\cos \alpha = \pm 1\). For \(\alpha = 0\) or \(\alpha = \pi \) when \({{L}_{1}},{{L}_{2}}\) are parallel, \({\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) is guaranteed by \({\text{AT}}(a,b;d,\alpha ) = {\text{sign}}(d)\pi {\text{/}}2 = 0\) when \(d = 0\) holds in addition to \(\alpha = 0\) or \(\alpha = \pi \).

The symmetry of the \({\text{AT}}\) function in \(a,b\), i.e. \({\text{AT}}(a,b;d,\alpha ) = {\text{AT}}(b,a;d,\alpha )\) implies that  \({\text{lk}}({{L}_{1}},{{L}_{2}}) = {\text{lk}}({{L}_{2}},{{L}_{1}})\) by Theorem 2. Since the \({\text{AT}}\) function is odd in \(d\), i.e., \({\text{AT}}(a,b; - d,\alpha ) = - {\text{AT}}(b,a;d,\alpha )\), Lemma 3 is also respected.

Proof (of Corollary 1). By definition any simple orthogonal line segments \({{L}_{1}},{{L}_{2}}\) have the angle \(\alpha = \pi {\text{/}}2\) and initial endpoints \({{a}_{1}} = 0 = {{a}_{2}}\), hence \({{b}_{1}} = {{l}_{1}}\), \({{b}_{2}} = {{l}_{2}}\). Then (3) gives \({\text{AT}}(0,{{l}_{2}};d,\pi {\text{/}}2) = 0\), \({\text{AT}}({{l}_{1}},0;d,\pi {\text{/}}2) = 0\), \({\text{AT}}(0,0;d,\pi {\text{/}}2) = 0\). Then \({\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}{\text{AT}}({{l}_{1}},{{l}_{2}};d,\alpha ) = - \frac{1}{{4\pi }}\arctan \left( {\frac{{{{l}_{1}}{{l}_{2}}}}{{d\sqrt {l_{1}^{2} + l_{2}^{2} + {{d}^{2}}} }}} \right)\) \({\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}{\text{AT}}({{l}_{1}},{{l}_{2}};d,\alpha ) = - \frac{1}{{4\pi }}\arctan \left( {\frac{{{{l}_{1}}{{l}_{2}}}}{{d\sqrt {l_{1}^{2} + l_{2}^{2} + {{d}^{2}}} }}} \right)\).

Figure 2 shows how the function \({\text{AT}}(a,b;d,\alpha )\) from Theorem 2 depends on two of four parameters when   the others are fixed. For example, if the angle \(\alpha = \pi {\text{/}}2\) is fixed, then \({\text{AT}}(a,b;d,\pi {\text{/}}2) = \arctan \left( {\frac{{ab}}{{d\sqrt {{{a}^{2}} + {{b}^{2}} + {{d}^{2}}} }}} \right)\). If also \(a = b\), the surface \({\text{AT}}(a,a;d,\pi {\text{/}}2) = \arctan \left( {\frac{{{{a}^{2}}}}{{d\sqrt {2{{a}^{2}} + {{d}^{2}}} }}} \right)\) \({\text{AT}}(a,a;d,\pi {\text{/}}2) = \arctan \left( {\frac{{{{a}^{2}}}}{{d\sqrt {2{{a}^{2}} + {{d}^{2}}} }}} \right)\) in the first picture of Fig. 2 has the horizontal ridge \({\text{AT}}(0,0;d,\pi {\text{/}}2) = 0\) and   \(\mathop {\lim }\limits_{d \to 0} {\text{AT}}(a,a;d,\pi {\text{/}}2) = {\text{sign}}(d)\pi {\text{/}}2\) for \(a \ne 0\). If \(d,\alpha \) are free, but \(a = 0\), then \({\text{AT}}(0,0;d,\alpha ) = \arctan \left( {\frac{{{{d}^{2}}\cot \alpha }}{{d\sqrt {{{d}^{2}}} }}} \right)\) = \({\text{sign}}(d)\arctan (\cot \alpha ) = {\text{sign}}(d)(\pi {\text{/}}2 - \alpha ).\) Similarly, \(\mathop {\lim }\limits_{d \to \infty } {\text{AT}}(0,\;0;d,\alpha ) = {\text{sign}}(d)(\pi {\text{/}}2 - \alpha )\), see the lines \({\text{AT}} = \pi {\text{/}}2 - \alpha \) on the boundaries of the AT surfaces in the middle pictures of Fig. 2.

Fig. 2.
figure 2

The graph of \({\text{AT}}(a,b;d,\alpha ) = \arctan \left( {\frac{{ab\sin \alpha + {{d}^{2}}\cot \alpha }}{{d\sqrt {{{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha + {{d}^{2}}} }}} \right)\), where 2 of 4 parameters are fixed. Top left: \(l = b - a = 0\), \(\alpha = \pi {\text{/}}2\). Top right: \(l = d = - 1\). Middle left: \(a = 0\), \(d = 1\). Middle right: \(a = 0\), \(l = 1\). Bottom left: \(a = 1\), \(\alpha = \pi {\text{/}}2\). Bottom right: \(d = - 1\), \(\alpha = \pi {\text{/}}2\).

Fig. 3.
figure 3

The linking number \({\text{lk}}(a,a + l;a,a + l;d,\alpha )\) from formula (3), where 2 of 4 parameters are fixed. Top left: \(l = 1\), \(\alpha = \pi {\text{/}}2\). Top right: \(l = 1\), \(d = - 1\). Middle left: \(a = 0\), \(d = 1\). Middle right: \(a = 0\), \(l = 1\). Bottom left: \(a = 0\), \(\alpha = \pi {\text{/}}2\). Bottom right: \(d = - 1\), \(\alpha = \pi {\text{/}}2\).

Lemma 4 (lk(L1,L2) is an integral in p, q). In the notations of Definition 2 we have

$${\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\int\limits_{{{a}_{2}}/d}^{{{b}_{2}}/d} {\frac{{\sin \alpha dpdq}}{{{{{(1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha )}}^{{3/2}}}}}} } $$

for \(d > 0\).

Proof. Below we assume that \({{a}_{1}}\), \({{a}_{2}}\), \({{l}_{1}}\), \({{l}_{2}}\), \(\alpha \) are given and \(t,s \in [0,1]\).

$${{L}_{1}}(t) = \left( {({{a}_{1}} + {{l}_{1}}t)\cos \frac{\alpha }{2},\; - {\kern 1pt} \left( {{{a}_{1}} + {{l}_{1}}t} \right)\sin \alpha ,\; - {\kern 1pt} \frac{d}{2}} \right),$$
$${{L}_{2}}(s) = \left( {({{a}_{2}} + {{l}_{2}}s)\cos \frac{\alpha }{2},\;({{a}_{2}} + {{l}_{2}}s)\sin \alpha ,\;\frac{d}{2}} \right),$$
$${{\dot {L}}_{1}}(t) = \left( {{{l}_{1}}\cos \frac{\alpha }{2},\; - {\kern 1pt} {{l}_{1}}\sin \frac{\alpha }{2},\;0} \right),$$
$${{\dot {L}}_{2}}(s) = \left( {{{l}_{2}}\cos \frac{\alpha }{2},\;{{l}_{2}}\sin \frac{\alpha }{2},\;0} \right),$$
$${{\dot {L}}_{1}}(t) \times {{\dot {L}}_{2}}(s) = \left( {0,\;0,\;2{{l}_{1}}{{l}_{2}}\sin \frac{\alpha }{2}\cos \frac{\alpha }{2}} \right) = \left( {0,\;0,\;{{l}_{1}}{{l}_{2}}\sin \alpha } \right),$$
$${{L}_{1}}(t) - {{L}_{2}}(s) = (({{a}_{1}} - {{a}_{2}} + {{l}_{1}}t - {{l}_{2}}s)\cos \alpha , - ({{a}_{1}} + {{a}_{2}} + {{l}_{1}}t + {{l}_{2}}s)\sin \alpha , - d),$$
$$\left( {{{{\dot {L}}}_{1}}(t),{{{\dot {L}}}_{2}}(s),{{L}_{1}}(t) - {{L}_{2}}(s)} \right) = - d{{l}_{1}}{{l}_{2}}\sin \alpha ,$$
$${\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{1}{{4\pi }}\int\limits_0^1 {\int\limits_0^1 {\frac{{({{{\dot {L}}}_{1}}(t),{{{\dot {L}}}_{2}}(s),{{L}_{1}}(t) - {{L}_{2}}(s))}}{{{{{\left| {{{L}_{1}}(t) - {{L}_{2}}(s)} \right|}}^{3}}}}dtds} } $$
$$ = \;\frac{1}{{4\pi }}\int\limits_0^1 {\int\limits_0^1 {\frac{{ - d{{l}_{1}}{{l}_{2}}\sin \alpha dtds}}{{{{{\left( {{{d}^{2}} + {{{({{a}_{1}} - {{a}_{2}} + {{l}_{1}}t - {{l}_{2}}s)}}^{2}}{{{\cos }}^{2}}\frac{\alpha }{2} + {{{({{a}_{1}} + {{a}_{2}} + {{l}_{1}}t + {{l}_{2}}s)}}^{2}}{{{\sin }}^{2}}\frac{\alpha }{2}} \right)}}^{{3/2}}}}}} } $$
$$ = \; - {\kern 1pt} {\kern 1pt} \frac{{d{{l}_{1}}{{l}_{2}}\sin \alpha }}{{4\pi }}\int\limits_0^1 {\int\limits_0^1 {\frac{{dtds}}{{{{{\left( {{{d}^{2}} + {{{({{a}_{1}} - {{a}_{2}} + {{l}_{1}}t - {{l}_{2}}s)}}^{2}}{{{\cos }}^{2}}\frac{\alpha }{2} + {{{({{a}_{1}} + {{a}_{2}} + {{l}_{1}}t + {{l}_{2}}s)}}^{2}}{{{\sin }}^{2}}\frac{\alpha }{2}} \right)}}^{{3/2}}}}}} } .$$

To simplify the last integral, introduce the variables \(p = ({{a}_{1}} + {{l}_{1}}t){\text{/}}d\) and \(q = ({{a}_{2}} + {{l}_{2}}s){\text{/}}d\). In the new variables \(p\), \(q\) the expression under the power \(3{\text{/}}2\) in the denominator becomes

$${{d}^{2}} + {{(pd - qd)}^{2}}{{\cos }^{2}}\frac{\alpha }{2} + {{(pd + qd)}^{2}}{{\sin }^{2}}\frac{\alpha }{2}$$
$$ = {{d}^{2}}\left( {1 + ({{p}^{2}} - 2pq + {{q}^{2}}){{{\cos }}^{2}}\frac{\alpha }{2} + ({{p}^{2}} + 2pq + {{q}^{2}}){{{\sin }}^{2}}\frac{\alpha }{2}} \right)$$
$$ = {{d}^{2}}\left( {1 + {{p}^{2}}\left( {{{{\cos }}^{2}}\frac{\alpha }{2} + {{{\sin }}^{2}}\frac{\alpha }{2}} \right) + {{q}^{2}} - 2pq\left( {{{{\cos }}^{2}}\frac{\alpha }{2} - {{{\sin }}^{2}}\frac{\alpha }{2}} \right)} \right)$$
$$ = \;{{d}^{2}}(1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha ).$$

The old variables are expressed as \(t = (pd - {{a}_{1}}){\text{/}}{{l}_{1}}\), \(s = (qd - {{a}_{2}}){\text{/}}{{l}_{2}}\) and have the differentials \(dt = \frac{d}{{{{l}_{1}}}}dp\), \(ds = \frac{d}{{{{l}_{2}}}}dq\). Since \(t,s \in [0,1]\), the new variables \(p,q\) have the ranges \(\left[ {{{a}_{1}}{\text{/}}d,{{b}_{1}}{\text{/}}d} \right]\) and \(\left[ {{{a}_{2}}{\text{/}}d,{{b}_{2}}{\text{/}}d} \right]\), respectively. Then we get the required expression:

$${\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{{d{{l}_{1}}{{l}_{2}}\sin \alpha }}{{4\pi }}\int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\int\limits_{{{a}_{2}}/d}^{{{b}_{2}}/d} {\frac{{{{d}^{2}}}}{{{{l}_{1}}{{l}_{2}}}}\frac{{dpdq}}{{{{d}^{3}}{{{(1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha )}}^{{3/2}}}}}} } $$
$$ = \; - {\kern 1pt} \frac{1}{{4\pi }}\int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\int\limits_{{{a}_{2}}/d}^{{{b}_{2}}/d} {\frac{{\sin \alpha dpdq}}{{{{{(1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha )}}^{{3/2}}}}}} } .$$

Due to Lemma 3, the above computations assume that the signed distance \(d > 0\).

Lemma 5 (the linking number as a single integral). In the notations of Definition 2 we have

$${\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{{I({{a}_{2}}{\text{/}}d) - I({{b}_{2}}{\text{/}}d)}}{{4\pi }},$$

where the function \(I(r)\) is defined as the single integral

$$I(r) = \int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\frac{{\sin \alpha (r - p\cos \alpha )dp}}{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha )\sqrt {1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha } }}} $$

for \(d > 0\).

Proof. Complete the square in the expression under power \(\frac{3}{2}\) in Lemma 4:

$$1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha = 1 + {{p}^{2}}{{\sin }^{2}}\alpha + {{(q - p\cos \alpha )}^{2}}.$$

The substitution \({{(q - p\cos \alpha )}^{2}} = (1 + {{p}^{2}}{{\sin }^{2}}\alpha ){{\tan }^{2}}\psi \) for the new variable \(\psi \) simplifies the sum of squares to \(1 + {{\tan }^{2}}\psi = 1{\text{/}}{{\cos }^{2}}\psi \). Since \(q\) varies within \(\left[ {{{a}_{2}}{\text{/}}d,{{b}_{2}}{\text{/}}d} \right]\), for any fixed \(p \in \left[ {{{a}_{1}}{\text{/}}d,{{b}_{1}}{\text{/}}d} \right]\), the range \([{{\psi }_{0}},{{\psi }_{1}}]\) of \(\psi \) satisfies \(\tan {{\psi }_{0}} = \frac{{{{a}_{2}}{\text{/}}d - p\cos \alpha }}{{\sqrt {1 + {{p}^{2}}{{{\sin }}^{2}}\alpha } }}\) and \(\tan {{\psi }_{1}} = \frac{{{{b}_{2}}{\text{/}}d - p\cos \alpha }}{{\sqrt {1 + {{p}^{2}}{{{\sin }}^{2}}\alpha } }}\). Since we treat \(p\), \(\psi \) as independent variables, the Jacobian of the substitution \((p,q) \mapsto (p,\psi )\) equals

$$\frac{{\partial q}}{{\partial \psi }} = \frac{\partial }{{\partial \psi }}\left( {p\cos \alpha + \tan \psi \sqrt {1 + {{p}^{2}}{{{\sin }}^{2}}\alpha } } \right) = \frac{{\sqrt {1 + {{p}^{2}}{{{\sin }}^{2}}\alpha } }}{{{{{\cos }}^{2}}\psi }}.$$

In the variables \(p,\psi \) the expression under the double integral of Lemma 4 becomes

$$\frac{{\sin \alpha dpdq}}{{{{{(1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha )}}^{{3/2}}}}} = \frac{{\sin \alpha dp}}{{{{{((1 + {{p}^{2}}{{{\sin }}^{2}}\alpha ) + (1 + {{p}^{2}}{{{\sin }}^{2}}\alpha ){{{\tan }}^{2}}\psi )}}^{{3/2}}}}}\frac{{\partial q}}{{\partial \psi }}d\psi $$
$$ = \;\frac{{\sin \alpha dp}}{{{{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha )}}^{{3/2}}}{{{(1 + {{{\tan }}^{2}}\psi )}}^{{3/2}}}}}\frac{{d\psi \sqrt {1 + {{p}^{2}}{{{\sin }}^{2}}\alpha } }}{{{{{\cos }}^{2}}\psi }} = \frac{{\sin \alpha dp\cos \psi d\psi }}{{1 + {{p}^{2}}{{{\sin }}^{2}}\alpha }},$$
$${\text{lk}} = - \frac{1}{{4\pi }}\int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\frac{{\sin \alpha dp}}{{1 + {{p}^{2}}{{{\sin }}^{2}}\alpha }}} \int\limits_{{{\psi }_{0}}}^{{{\psi }_{1}}} {\cos \psi d\psi } = \frac{1}{{4\pi }}\int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\frac{{\sin \alpha dp}}{{1 + {{p}^{2}}{{{\sin }}^{2}}\alpha }}(\sin {{\psi }_{0}} - \sin {{\psi }_{1}})} .$$

We can express the sin functions for the bounds \({{\psi }_{0}},{{\psi }_{1}}\) in terms of tan as \(\sin {{\psi }_{0}} = \tan {{\psi }_{0}}{\text{/}}\sqrt {1 + {{{\tan }}^{2}}{{\psi }_{0}}} \). Using \(\tan {{\psi }_{0}} = ({{a}_{2}}{\text{/}}d - p\cos \alpha ){\text{/}}\sqrt {1 + {{p}^{2}}{{{\sin }}^{2}}\alpha } \) obtained above, we get

$$\sqrt {1 + {{{\tan }}^{2}}{{\psi }_{0}}} = \sqrt {\frac{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha ) + {{{({{a}_{2}}{\text{/}}d - p\cos \alpha )}}^{2}}}}{{1 + {{p}^{2}}{{{\sin }}^{2}}\alpha }}} = \sqrt {\frac{{1 + {{p}^{2}} + {{{({{a}_{2}}{\text{/}}d)}}^{2}} - 2({{a}_{2}}{\text{/}}d)p\cos \alpha }}{{1 + {{p}^{2}}{{{\sin }}^{2}}\alpha }}} ,$$
$$\sin {{\psi }_{0}} = \frac{{{{a}_{2}}{\text{/}}d - p\cos \alpha }}{{\sqrt {1 + {{p}^{2}}{{{\sin }}^{2}}\alpha } }}\sqrt {\frac{{1 + {{p}^{2}}{{{\sin }}^{2}}\alpha }}{{1 + {{p}^{2}} + {{{({{a}_{2}}{\text{/}}d)}}^{2}} - 2\frac{{{{a}_{2}}}}{d}p\cos \alpha }}} = \frac{{{{a}_{2}}{\text{/}}d - p\cos \alpha }}{{\sqrt {1 + {{p}^{2}} + {{{({{a}_{2}}{\text{/}}d)}}^{2}} - 2({{a}_{2}}{\text{/}}d)p\cos \alpha } }}.$$

Then \(\sin {{\psi }_{1}}\) has the same expression with \({{a}_{2}}\) replaced by \({{b}_{2}}\). After substituting these expressions in the previous formula for the linking number, we get

$${\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{1}{{4\pi }}\int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\frac{{\sin \alpha dp}}{{1 + {{p}^{2}}{{{\sin }}^{2}}\alpha }}} \left( {\frac{{{{a}_{2}}{\text{/}}d - p\cos \alpha }}{{\sqrt {1 + {{p}^{2}} + {{{({{a}_{2}}{\text{/}}d)}}^{2}} - 2({{a}_{2}}{\text{/}}d)p\cos \alpha } }}} \right.$$
$$\left. { - \;\frac{{{{b}_{2}}{\text{/}}d - p\cos \alpha }}{{\sqrt {1 + {{p}^{2}} + {{{({{b}_{2}}{\text{/}}d)}}^{2}} - 2({{b}_{2}}{\text{/}}d)p\cos \alpha } }}} \right) = \frac{{I({{a}_{2}}{\text{/}}d) - I({{b}_{2}}{\text{/}}d)}}{{4\pi }}$$

for

$$I(r) = \int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\frac{{\sin \alpha (r - p\cos \alpha )dp}}{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha )\sqrt {1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha } }}} .$$

Lemma 6 (I(r) via arctan). The integral \(I(r)\) in Lemma 5 can be found as

$$\int \frac{{\sin \alpha (r - p\cos \alpha )dp}}{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha )\sqrt {1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha } }} = \arctan \frac{{pr\sin \alpha + \cot \alpha }}{{\sqrt {1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha } }} + C.$$

Proof. The easy way is to differentiate \(\arctan \omega \) for ω = \((pr{{\sin }^{2}}\alpha + \) \(\omega = (pr{{\sin }^{2}}\alpha + \cos \alpha ){\text{/}}{\kern 1pt} \sin \alpha \sqrt {1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha } \) with respect to the variable \(p\) remembering that \(r,\alpha \) are fixed parameters. For notational clarity, we use an auxiliary symbol for the expression under the square root: \(R = 1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha \). Then \(\omega = (pr{{\sin }^{2}}\alpha + \cos \alpha ){\text{/}}{\kern 1pt} \sin \alpha \sqrt R \) and

$$\frac{{d\omega }}{{dp}} = \frac{1}{{R\sin \alpha }}\left( {r{{{\sin }}^{2}}\alpha \sqrt R - (rp{{{\sin }}^{2}}\alpha + \cos \alpha )\frac{{2p - 2r\cos \alpha }}{{2\sqrt R }}} \right)$$
$$ = \;\frac{1}{{R\sqrt R \sin \alpha }}\left( {r{{{\sin }}^{2}}\alpha (1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha ) - (rp{{{\sin }}^{2}}\alpha + \cos \alpha )(p - r\cos \alpha )} \right)$$
$$ = \;\frac{{r{{p}^{2}}{{{\sin }}^{2}}\alpha + {{r}^{3}}{{{\sin }}^{2}}\alpha - 2p{{r}^{2}}\cos \alpha {{{\sin }}^{2}}\alpha - r{{p}^{2}}{{{\sin }}^{2}}\alpha + p{{r}^{2}}\cos \alpha {{{\sin }}^{2}}\alpha - p\cos \alpha + r}}{{R\sqrt R \sin \alpha }}$$
$$ = \;\frac{{{{r}^{3}}{{{\sin }}^{2}}\alpha - p{{r}^{2}}\cos \alpha {{{\sin }}^{2}}\alpha - p\cos \alpha + r}}{{R\sqrt R \sin \alpha }} = \frac{{(r - p\cos \alpha )(1 + {{r}^{2}}{{{\sin }}^{2}}\alpha )}}{{R\sqrt R \sin \alpha }},$$
$$\frac{d}{{dp}}\arctan \omega = \frac{1}{{1 + {{\omega }^{2}}}}\frac{{d\omega }}{{dp}} = \frac{{{{{(\sin \alpha \sqrt R )}}^{2}}}}{{{{{(\sin \alpha \sqrt R )}}^{2}} + {{{(pr{{{\sin }}^{2}}\alpha + \cos \alpha )}}^{2}}}}\frac{{d\omega }}{{dp}}$$
$$ = \frac{{R{{{\sin }}^{2}}\alpha }}{{R{{{\sin }}^{2}}\alpha + ({{p}^{2}}{{r}^{2}}{{{\sin }}^{4}}\alpha + 2pr{{{\sin }}^{2}}\alpha \cos \alpha + {{{\cos }}^{2}}\alpha )}}\frac{{(r - p\cos \alpha )(1 + {{r}^{2}}{{{\sin }}^{2}}\alpha )}}{{R\sqrt R \sin \alpha }}$$
$$ = \frac{{\sin \alpha }}{{\sqrt R }}\frac{{(r - p\cos \alpha )(1 + {{r}^{2}}{{{\sin }}^{2}}\alpha )}}{{{{{\sin }}^{2}}\alpha (1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha ) + ({{p}^{2}}{{r}^{2}}{{{\sin }}^{4}}\alpha + 2pr{{{\sin }}^{2}}\alpha \cos \alpha + {{{\cos }}^{2}}\alpha )}}$$
$$ = \;\frac{{\sin \alpha (r - p\cos \alpha )(1 + {{r}^{2}}{{{\sin }}^{2}}\alpha )}}{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha + {{r}^{2}}{{{\sin }}^{2}}\alpha + {{p}^{2}}{{r}^{2}}{{{\sin }}^{4}}\alpha )\sqrt R }} = \frac{{\sin \alpha (r - p\cos \alpha )(1 + {{r}^{2}}{{{\sin }}^{2}}\alpha )}}{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha )(1 + {{r}^{2}}{{{\sin }}^{2}}\alpha )\sqrt R }}$$
$$ = \;\frac{{\sin \alpha (r - p\cos \alpha )}}{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha )\sqrt R }} = \frac{{\sin \alpha (r - p\cos \alpha )}}{{(1 + {{p}^{2}}{{{\sin }}^{2}}\alpha )\sqrt {1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha } }}.$$

Since we got the required expression under the integral \(I(r)\), Lemma 6 is proved.

Proof (Theorem 2). Consider the right hand side of the equation in Lemma 6 as the 3-variable function \(F(p,r;\alpha ) = \arctan \left( {\frac{{pr\sin \alpha + \cot \alpha }}{{\sqrt {1 + {{p}^{2}} + {{r}^{2}} - 2pr\cos \alpha } }}} \right)\). The function in Lemma 5 is \(I(r) = F({{b}_{1}}{\text{/}}d,r;\alpha ) - \) \(F({{a}_{1}}{\text{/}}d,r;\alpha )\). By Lemma 5

$${\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{{(F({{b}_{1}}{\text{/}}d,{{a}_{2}}{\text{/}}d;\alpha ) - F({{a}_{1}}{\text{/}}d,{{a}_{2}}{\text{/}}d;\alpha )) - (F({{b}_{1}}{\text{/}}d,{{b}_{2}}{\text{/}}d;\alpha ) - F({{a}_{1}}{\text{/}}d,{{b}_{2}}{\text{/}}d;\alpha ))}}{{4\pi }}.$$

Rewrite a typical function from the numerator above as follows:

$$F\left( {a{\text{/}}d,b{\text{/}}d;\alpha } \right) = \arctan \frac{{(ab{\text{/}}{{d}^{2}})\sin \alpha + \cot \alpha }}{{\sqrt {1 + {{{(a{\text{/}}d)}}^{2}} + {{{(b{\text{/}}d)}}^{2}} - 2(ab{\text{/}}{{d}^{2}})\cos \alpha } }} = \arctan \frac{{ab\sin \alpha + {{d}^{2}}\cot \alpha }}{{d\sqrt {{{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha + {{d}^{2}}} }}.$$

If we denote the last expression as \({\text{AT}}(a,b;d,\alpha )\), required formula (3) follows.

In Lemmas 4, 5 and above we have used that the signed distance \(d\) is positive. By Lemma 3 the signed distance \(d\) and \({\text{lk}}({{L}_{1}},{{L}_{2}})\) simultaneously change their signs under a central symmetry, while all other invariants remain the same. Since \({\text{AT}}(a,b; - d,\alpha ) = - {\text{AT}}(a,b;d,\alpha )\) due to the arctan function being odd, formula (3) holds for \(d < 0\). The formula remains valid even for \(d = 0\), when \({{L}_{1}}\), \({{L}_{2}}\) are in the same plane. The expected value \({\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) needs an explicit setting, see the discussion of the linking number discontinuity around \(d = 0\) in Corollary 4.

6 THE ASYMPTOTIC BEHAVIOUR OF THE LINKING NUMBER OF SEGMENTS

This section discusses how the linking number \({\text{lk}}({{L}_{1}},{{L}_{2}})\) in Theorem 2 behaves with respect to the six parameters of line segments \({{L}_{1}}\), \({{L}_{2}}\). Figure 3 shows how the linking number between two equal line segments varies with different pairs of parameters.

Corollary 2 (bounds of the linking number). For any line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\), the linking number \({\text{lk}}({{L}_{1}},{{L}_{2}})\) is between \( \pm 1{\text{/}}2\).

Proof. By Theorem 2 \({\text{lk}}({{L}_{1}},{{L}_{2}})\) is a sum of four arctan functions divided by \(4\pi \). Since each arctan is strictly between \( \pm \pi {\text{/}}2\), the linking number is between \( \pm 1{\text{/}}2\).

Corollary 3 (sign of the linking number). In the notation of Definition 2, we have \(\mathop {\lim }\limits_{\alpha \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = 0 = \mathop {\lim }\limits_{\alpha \to \pi } {\text{lk}}({{L}_{1}},{{L}_{2}})\). Any non-parallel \({{L}_{1}},{{L}_{2}}\) have \({\text{sign}}({\text{lk}}({{L}_{1}},{{L}_{2}})) = - {\text{sign}}(d)\). So \({\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) if and only if \(d = 0\) or \(\alpha = 0\) or \(\alpha = \pi \).

Proof. If \(\alpha = 0\) or \(\alpha = \pi \), then \(\cot \alpha \) is undefined, so Theorem 2 sets \({\text{AT}}(a,b;d,\alpha ) = {\text{sign}}(d)\pi {\text{/}}2\). Then \({\text{lk}}({{L}_{1}},{{L}_{2}}) = {\text{sign}}(d)(\pi {\text{/}}2)(1 + 1 - 1 - 1) = 0\).

Theorem 2 also specifies that \({\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) for \(d = 0\). If \(d \ne 0\) and \(\alpha \to 0\) within \([0,\pi ]\) while all other parameters remain fixed, then \({{d}^{2}}\cot \alpha \to + \infty \). Hence each of the four arctan functions in Theorem 2 approaches \(d\pi {\text{/}}2\), so \({\text{lk}}({{L}_{1}},{{L}_{2}}) \to 0\). The same conclusion similarly follows in the case \(\alpha \to \pi \) when \({{d}^{2}}\cot \alpha \to - \infty \).

If \({{L}_{1}}\), \({{L}_{2}}\) are not parallel, the angle \(\alpha \) between them belongs to \((0,\pi )\). If \(d > 0\), Lemma 4 says that

$${\text{lk}}({{L}_{1}},{{L}_{2}}) = - \frac{1}{{4\pi }}\int\limits_{{{a}_{1}}/d}^{{{b}_{1}}/d} {\int\limits_{{{a}_{2}}/d}^{{{b}_{2}}/d} {\frac{{\sin \alpha dpdq}}{{{{{(1 + {{p}^{2}} + {{q}^{2}} - 2pq\cos \alpha )}}^{{3/2}}}}}} } .$$

Since the function under the integral is strictly positive, \({\text{lk}}({{L}_{1}},{{L}_{2}}) < 0\). By Lemma 3 both \({\text{lk}}({{L}_{1}},{{L}_{2}})\) simultaneously change their signs under a central symmetry. Hence the formula \({\text{sign}}({\text{lk}}({{L}_{1}},{{L}_{2}})) = - {\text{sign}}(d)\) holds for all \(d\) including \(d = 0\) above.

Corollary 4 (lk for d → 0). If the distance \(d \to 0\) and the curves \({{L}_{1}}\), \({{L}_{2}}\) remain disjoint, the expression in formula (3) behaves continuously, so \(\mathop {\lim }\limits_{d \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\). If \(d \to 0\) and the interiors of \({{L}_{1}}\), \({{L}_{2}}\) intersect each other in the limit case \(d = 0\), then \(\mathop {\lim }\limits_{d \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = - {\text{sign}}(d){\text{/}}2\), where \(d \to 0\) keeps its sign.

Proof. Recall that \(\mathop {\lim }\limits_{x \to \pm \infty } \arctan x = \pm \frac{\pi }{2}\). By Corollary 3 assume that \(\alpha \ne 0,\alpha \ne \pi \), so \(\alpha \in (0,\pi )\). Then \(\sin \alpha > 0\), \({{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha > (a - b{{)}^{2}} \geqslant 0\) and

$$\mathop {\lim }\limits_{d \to 0} {\text{AT}}(a,b;d,\alpha ) = \mathop {\lim }\limits_{d \to 0} \arctan \left( {\frac{{ab\sin \alpha + {{d}^{2}}\cot \alpha }}{{d\sqrt {{{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha + {{d}^{2}}} }}} \right) = {\text{sign}}(a){\text{sign}}(b){\text{sign}}(d)\frac{\pi }{2},$$

so Theorem 2 gives

$$\mathop {\lim }\limits_{d \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{{{\text{sign}}(d)}}{8}({\text{sign}}({{a}_{1}}) - {\text{sign}}({{b}_{1}}))({\text{sign}}({{b}_{2}}) - {\text{sign}}({{a}_{2}})).$$

In the limit case \(d = 0\), the line segments \({{L}_{1}},{{L}_{2}} \subset \{ z = 0\} \) remain disjoint in the same plane if and only if both endpoint coordinates \({{a}_{i}}\), \({{b}_{i}}\) have the same sign for at least one of \(i = 1,\;2\), which is equivalent to \({\text{sign}}({{a}_{i}}) - {\text{sign}}({{b}_{i}}) = 0\), i.e. \(\mathop {\lim }\limits_{d \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) from the product above. Hence formula (3) is continuous under \(d \to 0\) for any non-crossing segments. Any segments that intersect in the plane \(\{ z = 0\} \) when \(d = 0\) have endpoint coordinates \({{a}_{i}} < 0 < {{b}_{i}}\) for both \(i = 1,\;2\) and have the limit \(\mathop {\lim }\limits_{d \to 0} {\text{lk}}({{L}_{1}},{{L}_{2}}) = \frac{{{\text{sign}}(d)}}{8}( - 1 - 1)(1 - ( - 1)) = - \frac{{{\text{sign}}(d)}}{2}\) as required.

Corollary 5 (lk for \(d \to \pm \infty \)). If the distance \(d \to \pm \infty \), then \({\text{lk}}({{L}_{1}},{{L}_{2}}) \to 0\).

Proof. If \(d \to \pm \infty \), while other parameters of \({{L}_{1}},{{L}_{2}}\) remain fixed, then the function

$${\text{AT}}(a,b;d,\alpha ) = \arctan \left( {\frac{{ab\sin \alpha + {{d}^{2}}\cot \alpha }}{{d\sqrt {{{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha + {{d}^{2}}} }}} \right)$$

from Theorem 2 has the limit \(\arctan ({\text{sign}}(d)\cot \alpha ) = {\text{sign}}(d)(\pi {\text{/}}2 - \alpha )\). Since the four AT functions in Theorem 2 include the same values of \(d,\alpha \), their limits cancel, so \({\text{lk}}({{L}_{1}},{{L}_{2}}) \to 0\).

Corollary 6 (lk for \({{a}_{i}},{{b}_{i}} \to \infty \)). If the invariants \(d\), \(\alpha \) of line segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) remain fixed, but \({{a}_{i}} \to + \infty \) or \({{b}_{i}} \to - \infty \) for each \(i = 1,2\), then \({\text{lk}}({{L}_{1}},{{L}_{2}}) \to 0\).

Proof. If \({{a}_{i}} \to + \infty \), then \({{a}_{i}} \leqslant {{b}_{i}} \to + \infty \), \(i = 1,2\). If \({{b}_{i}} \to - \infty \), then \({{b}_{i}} \geqslant {{a}_{i}} \to - \infty \), \(i = 1,\;2\). Consider the   former case \({{a}_{i}} \to + \infty \), the latter is similar. Since \(d,\alpha \) are fixed, \({{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha + {{d}^{2}} \leqslant {{(a + b)}^{2}} + {{d}^{2}} \leqslant 5{{b}^{2}}\) for large enough \(b\). Since \(\arctan (x)\) increases,

$${\text{AT}}(a,b;d,\alpha ) \geqslant \arctan \left( {\frac{{ab\sin \alpha + {{d}^{2}}\cot \alpha }}{{db\sqrt 5 }}} \right) \to {\text{sign}}(d)\frac{\pi }{2}$$

as \(b \geqslant a \to + \infty \). Since the four AT functions in Theorem 2 have the same limit when their first two arguments tend to \( + \infty \), these 4 limits cancel, so \({\text{lk}}({{L}_{1}},{{L}_{2}}) \to 0\).

Corollary 7 (lk for \({{a}_{i}} \to {{b}_{i}}\)). If one of segments \({{L}_{1}},{{L}_{2}} \subset {{\mathbb{R}}^{3}}\) becomes infinitely short so that its final endpoint tends to the fixed initial endpoint (or vice versa), while all other invariants of \({{L}_{1}}\), \({{L}_{2}}\) from Definition 2 remain fixed, then \({\text{lk}}({{L}_{1}},{{L}_{2}}) \to 0\).

Proof. We show that \({\text{lk}}({{L}_{1}},{{L}_{2}}) = 0\) for \(d = 0\). It’s enough to consider the case \(d \ne 0\). Then

$${\text{AT}}(a,b;d,\alpha ) = \arctan \left( {\frac{{ab\sin \alpha + {{d}^{2}}\cot \alpha }}{{d\sqrt {{{a}^{2}} + {{b}^{2}} - 2ab\cos \alpha + {{d}^{2}}} }}} \right)$$

is continuous. Let (say for \(i = 1\)) \({{a}_{1}} \to {{b}_{1}}\), the case \({{b}_{1}} \to {{a}_{1}}\) is similar. The continuity of \({\text{AT}}\) implies that \({\text{AT}}({{a}_{1}},{{b}_{2}};d,\alpha ) \to {\text{AT}}({{b}_{1}},{{b}_{2}};d,\alpha )\) and \({\text{AT}}({{a}_{1}},{{a}_{2}};d,\alpha ) \to {\text{AT}}({{b}_{1}},{{a}_{2}};d,\alpha )\). In the limit all terms in Theorem 2 cancel, hence \({\text{lk}}({{L}_{1}},{{L}_{2}}) \to 0\).

7 COMPUTATIONS OF THE LINKING NUMBER FOR POLYGONAL LINKS

If curves \({{\gamma }_{1}},{{\gamma }_{2}} \subset {{\mathbb{R}}^{3}}\) consist of straight line segments, then \({\text{lk}}({{\gamma }_{1}},{{\gamma }_{2}})\) can be computed as the sum of \({\text{lk}}({{L}_{1}},{{L}_{2}})\) over all line segments \({{L}_{1}} \subset {{\gamma }_{1}}\) and \({{L}_{2}} \subset {{\gamma }_{2}}\). In [20] there is a complex proof that this sum is convergent for a cubical lattice. The convergence of the periodic linking numbers remains open for arbitrary lattices.

Figure 4 shows polygonal links whose linking numbers were computed by our Python code implementing formula (3) at https://github.com/MattB-242/Closed_Lk_Form. For all links in Fig. 4formula (3) calculates the linking number between the two components correctly (as equal to \( - 1\) and \( + 1\) respectively in the orientations given in Fig. 4), with a computation error of less than \({{10}^{{ - 12}}}\).

Fig. 4.
figure 4

(1) The Hopf link as two square cycles has \({\text{lk}} = - 1\) and vertices with coordinates \({{L}_{1}} = ( - 2,0, - {\kern 1pt} 2),\) \((2,0, - 2),\) \((2,0,2),\) \(( - 2,0,2)\), \({{L}_{2}} = ( - 1, - 2,0),\) \(( - 1,2,0),\) \((1,2,0),\) \((1, - 2,0)\) (2) The Hopf link of triangular cycles has \({\text{lk}} = + 1\), \({{L}_{1}} = ( - 1,0, - {\kern 1pt} 1),\) \(( - 1,0,1),\) \((1,0,0)\) and \({{L}_{2}} = (0,0,0),\) \((2,1,0),\) \((2, - 1,0)\). (3) Solomon’s link has \({\text{lk}} = + 2\), \({{L}_{1}} = ( - 1,1,1),\) \(( - 1, - {\kern 1pt} 1,1),\) \((3, - 1,1),\) \((3,1, - 1),\) \((1,1, - 1),\) \((1,1,1)\) and \({{L}_{2}} = (0, - 2, - 2),\) \((0, - 2,0),\) \((2,2,0),\) \((2,0,0),\) \((0,2,0),\) \((2,0,0),\) \((2,0, - 2),\) \((2, - 2, - 2),\)\((0, - 2, - 2)\). (4) Whitehead’s link has \({\text{lk}} = 0\), \({{L}_{1}} = ( - 1,0,1),\) \((1,0,1),\) \((0,0, - 2),\) \((0,1, - 2),\) \(( - 1,1, - 2),\) \(( - 2, - 1,3),\) \((1, - 1,3),\) \(( - 1,0, - 3)\), \(( - 1,2, - 3),\) \(( - 1,2,1)\) and \({{L}_{2}} = (0, - 2, - 1),\) \((0,2, - 1),\) \((0,2,2),\) \((0, - 2,2)\).

The asymptotic linking number introduced by Arnold converges for infinitely long curves [24], while our motivation was a computation of geometric and topology invariants to classify periodic structures such as textiles [7] and crystals [11].

Theorem 2 allows us to compute the periodic linking number between a segment \(J\) and a growing finite lattice \({{L}_{n}}\) whose unit cell consists of \(n\) copies of two oppositely oriented segments orthogonal to \(J\). This periodic linking number is computed for increasing \(n\) in a lattice extending periodically in one, two and three directions, see Fig. 5. As \(n\) increases, the \({\text{lk}}\) function asymptotically approaches an approximate value of \(0.30\) for 1- and 3-periodic lattice and \(0.29\) for the 2-periodic lattice.

Fig. 5.
figure 5

Left: the line segment \(J = (0,0, - 1) + t(0,0,2)\) in red and the periodic lattice \(L({{n}^{k}})\) derived from \(n\) copies of the “unit cell” \(L = \{ ( - 1, - 1,0) + t(0,2,0),( - 1,1,0) + s(0, - 2,0)\} \), \(t,s \in [0,1]\), translated in \(k\) linearly independent directions for increasing \(n \in \mathbb{Z}\). Right: the periodic linking number \({\text{lk}}(J,L({{n}^{k}}))\) is converging fast for \(n \to + \infty \). (Top) \(k = 1\). Middle: \(k = 2\). Bottom: \(k = 3\).

The invariant-based formula has allowed us to prove new asymptotic results of the linking number in Corollaries 2–7 of Section 6. Since the periodic linking number is a real-valued invariant modulo isometries, it can be used to continuously quantify similarities between periodic crystalline networks [11]. One next possible step is to use formula (3) to prove asymptotic convergence of the periodic linking number for arbitrary lattices, so that we can show that the limit of the infinite sum is a general invariant that can be used to develop descriptors of crystal structures.

The Milnor invariants generalise the linking number to invariants of links with more than two components. An integral for the three component Milnor invariant [12] may be possible to compute in a closed form similarly to Theorem 2. The interesting open problem is to extend the isometry-based approach to finer invariants of knots.

The Gauss integral in (1) was extended to the infinite Kontsevich integral containing all finite-type or Vassiliev’s invariants of knots [15]. The coefficients of this infinite series were explicitly described [16] as solutions of exponential equations with non-commutative variables \(x\), \(y\) in a compressed form modulo commutators of commutators in \(x\), \(y\). The underlying metabelian formula for \(\ln ({{e}^{x}}{{e}^{y}})\) has found an easier proof [17] in the form of a generating series in the variables \(x\), \(y\).

8 CONCLUSIONS AND POTENTIAL EXTENSIONS TO PERIODIC STRUCTURES

This paper has provided a detailed proof of the analytic formula for the linking number based on six isometry invariants that uniquely determine a relative position of two line segments in \({{\mathbb{R}}^{3}}\). Though a similar formula was claimed in [14], no proof was given. Hence this paper fills an important gap in the literature by completing the previously missing proof via highly technical Lemmas 4–6 in Section 5.

We were motivated by detecting inter-penetrations of crystalline networks [11]. Solid crystalline materials (crystals) are periodic structures, which are determined in a rigid form and can be naturally classified up to isometry preserving all inter-atomic distances. The first complete isometry invariant of crystals was found in [3]. The harder problem is to design a continuous metric between crystals. Well-approximated metrics between lattices in any dimension were defined in the first paper [19] in the new area of Periodic Geometry [2]. Both classification and metric problems can be combined into the more practically important mapping problem asking for a continuous parameterization of all crystals. Such parameterizations were described for lattices in dimensions two [10] and three [9]. For general crystals, the easiest complete invariants are Pointwise Distance Distributions [26] whose simpler averages [27] are enough to predict the lattice energy of crystals within 5 kJ/mol [23].