Geometry: "Repulsion" between two lines in three dimensional space Given two points in three (or, any) dimensional space, the distance between these two can easily be plugged into a function to return a value for repulsion or attraction, ideally this function is derivable.
If I have two lines, i.e. one pair of points and another pair of points, is something similar possible without discretizing the line and calculating a lot of pairwise point-repulsions?
If it is not possible for two lines with defined end points, is it possible for two infinite rays?
 A: Suppose the function for two points works as follows
$$f:\mathbb{R}^3\times\mathbb{R}^3\to\mathbb{R}: (\vec{x},\vec{y}) \mapsto f(\vec{x},\vec{y})$$
then, you can in principle extend this notion for lines by performing an integral as pointed out in the comments
$$\int_c^d\int_a^b  f(\vec{x}(t),\vec{y}(s)) \|\vec{x}'(t)\| \|\vec{y}'(s)\| dtds$$
where
$$\vec{x}:[a,b]\to\mathbb{R}^3:t\mapsto \vec{x}(t)$$
and
$$\vec{y}:[c,d]\to\mathbb{R}^3:s\mapsto \vec{y}(s)$$
are parametrizations of the lines.
A: For any two subsets $L_1, L_2 \subset \mathbb{R}^{3}$, you can define a distance between them by taking the greatest lower bound of the distances between points in $L_1$ and $L_2$:
$$d( L_1, L_2 ) = \inf \{\;|\vec{x}_1 - \vec{x}_2| : \vec{x}_1 \in L_1, \vec{x}_2 \in L_2\;\}$$
When $L_1, L_2$ are "infinite" lines and if you want to assign a rotational/translation invariant potential energy $U(L_1,L_2)$ between them, the energy will depend only on two parameters:


*

*The distance $d(L_1, L_2)$ above and the "angle" $\theta(L_1,L_2)$ between them.


Let's say you have given paramatrization of you lines $L_1$ and $L_2$ as:
$$L_1 = \{\; \vec{x}_1 + \lambda \vec{t}_1 : \lambda \in \mathbb{R} \;\}
\quad\text{ and }\quad
  L_2 = \{\; \vec{x}_2 + \lambda \vec{t}_2 : \lambda \in \mathbb{R} \;\}
$$
where $\vec{x}_i$ are a point of $L_i$ and $\vec{t}_i$ is a unit tangent vector for $L_i$. You can compute the angle and distance between $L_1$ and $L_2$ by simple vector arithmetics:
$$\begin{align}
\theta(L_1,L_2) &= \cos^{-1}(\vec{t}_1\cdot\vec{t}_2)\\
d(L_1,L_2)     &= | \mathscr{P}( 
\mathscr{P}( \vec{x}_1 - \vec{x}_2, \vec{t}_1 ), 
\mathscr{P}(\vec{t}_2, \vec{t}_1)) |
\end{align}$$
where $\mathscr{P}(\vec{x},\vec{v}) = \vec{x} - \frac{(\vec{x}\cdot\vec{v})\vec{v}}{|\vec{v}|^2}$ stands for taking the component of $\vec{x}$ perpendicular to any non-zero vector $\vec{v}$. Please note that in the special case $\vec{t}_1$ parallel to $\vec{t}_2$, $\mathscr{P}(\vec{t}_1, \vec{t}_2) = \vec{0}$ and there is no need to apply the outermost projection.
If you want to construct $U(L_1, L_2)$ as some sort of integral of radial symmetric/translation invariant interaction energy between points on $L_1$ and $L_2$. i.e. taking integrals of the form:
$$U(L_1,L_2) = \iint_{\vec{x}_1 \in L_1, \vec{x}_2 \in L_2} \phi( |\vec{x}_1 - \vec{x}_2| )$$
The end result always look like this:
$$\frac{F( d(L_1,L_2) )}{|\sin\theta(L_1,L_2)|}$$
The "radial" dependence will be a function of $d(L_1,L_2)$ alone and the "angular" dependence blow up when the lines are parallel. 
When $L_1$ and $L_2$ are "infinite" rays instead of "infinite" lines, the integral no longer has such simple form. However, the integral still blows up if your two rays are "parallel" and pointing in the same direction.
What's next depends on what you need to do with the lines. If you just want some way
to create a bunch of random lines not clumped together, you can just forget doing any integral and define your $U(L_1,L_2)$ directly.
