Find a parametric line equation that intersects two other lines at the point of closest approach I have two parametric line equations for a 3D space, $A(t)$ and $B(t)$. Both of these lines have a "velocity" vector as a direction vector. Both equations actually represent a point moving through space at a specific speed, and the line represents its path through space. Each line equation has a different "speed".
So, I have these two line equations that actually represent moving points (think two mosquitos travelling in straight lines at different speeds).
I need to find a line equation that will "hit" both $A(t)$ and $B(t)$ (think bug spray, trying to hit the mosquitoes). This line also has a "velocity" (and thus "speed"). However, once the line intersects ("hits" is the term I used above) one of the other lines ($A(t)$ or $B(t)$), it will take some amount of time for it to intersect the other (as it is travelling at a constant speed, and not instantaneously). However, I need this line equation to travel the least possible distance between intersecting one line and then the other.
My problem arises in finding this line equation, specifically the direction vector. I need the third line to almost "predict" the future location of the lines - it hits one (say, $A(t)$) and then, because both $B(t)$ and the (not yet found) line would be travelling at different speeds, the (not yet found) line would need to be perfectly position to intersect $B(t)$.
So far, I've deduced that the third line will intersect $B(t)$ at $t = t_c - a$ and $A(t)$ at $t = t_c + b$ ($B(t)$ travels faster than $A(t)$, and thus the third line must intersect it first). $t_c$ is the $t$ value when $A(t)$ and $B(t)$ are closest together. $a$ and $b$ are some real values that represent seconds (the same unit as $t$).
I don't know where to go from here, or if I'm even on the right track. How could you find a line that intersects two other lines, with different velocities, while also minimising the distance the third line travels between intersecting the other lines?
I was hoping for some insight into the problem (specific values weren't provided for this reason - I don't need the full working, I just need some guidance to the solution). This is a fairly unique problem, as the lines I am dealing with actually represent a point moving through a 3D space.
Thanks for any help.
 A: Let $A(t)=tA_1+a_1$ and $B(t)=tB_1+b_1$ be your two lines.
Then $C=A_1\times B_1$ is a direction perpendicular to both directions $A_1,B_1$. Also this determine two planes $\Pi_1$ and $\Pi_2$ which contains directions $A_1$ and $B_1$ respectively.
With the vector $\vec{a_1b_1}$ we construct a triangle with vertices
$a_1,b_1$ and $E$. This last direction (also position) being the projection of the vector
$\vec{a_1b_1}$ on $\Pi_1$. Now we consider the Ansatz:
$$\vec{a_1b_1}=E+mC.$$
Pairing each side of this equation with $C$ we get
$\vec{a_1b_1}\cdot C=mC\cdot C$. We get this because $E$ and $C$ are perpendicular, so
$$m=\frac{\vec{a_1b_1}\cdot C}{C\cdot C},$$
and
$E=\vec{a_1b_1}-mC$ is got as a byproduct.
$\hspace{4cm}$
A: In this answer I assume that the third line has a given speed $v$, and that the lines are not parallel. If the speed is just a maximum then this may not be the optimal solution. Let the first curve be given by
$$
\mathbf{l}_1 = t\mathbf{b}.
$$
Here we have just translated to remove one of the vectors. Suppose the second curve is given by
$$
\mathbf{l}_2 = \mathbf{a}' + t\mathbf{b}'
$$
Then if we leave at $\mathbf{l}_1$ at $t_1$ and arrive at $\mathbf{l}_2$ at $t_2$, we can calculate the vector between the points of intersection:
$$
\mathbf{d}(t_1, t_2) = \mathbf{a}' + t_2\mathbf{b}' - t_1\mathbf{b}.
$$
We know that
$$
\frac{\|\mathbf{d}\|}{t_2 - t_1} = v,
$$
and so
$$
t_2 = t_1 + \frac{\|\mathbf{d}\|}{v}. 
$$
Hence
$$
\begin{align}
\|\mathbf{d}\|^2 &= (\mathbf{a}' + t_2\mathbf{b}' - t_1\mathbf{b}).(\mathbf{a}' + t_2\mathbf{b}' - t_1\mathbf{b}) \\
&= \left(\mathbf{a}' + \frac{\|\mathbf d\|}{v}\mathbf{b}' + t_1(\mathbf{b}' - \mathbf{b})\right).\left(\mathbf{a}' + \frac{\|\mathbf d\|}{v}\mathbf{b}' + t_1(\mathbf{b}' - \mathbf{b})\right) 
\end{align}
$$
Which is a quadratic equation for $\|\mathbf d\|$ in terms of $t_1$ - if the roots are not real then this implies that we can't hit the other line when setting off from $\mathbf l_1$ at time $\mathbf t_1$.
We can rearrange the above equation to get an equation of the form
$$
\|d\|^2 - 2\beta(t_1)\|d\| + \gamma(t_1) = 0
$$
and so, from the quadratic formula
$$ 
 \|d\|(t_1) = \beta(t_1) \pm \sqrt{\beta(t_1)^2 - \gamma(t_1)} = f(t_1).
$$
where the appropriate root is chosen (this will depend on properties of the lines).
$\beta$ and $\gamma$ are smooth functions of $t$, so we can differentiate $f$ to find the critical points of the distance.
