I would like to come with an algorithm to find the midpoint of the shortest between 2 rays a+tb and c+sd, where t and s are scalars. I have a scenario which I try to depict like this.
One of the strategies I was planning to try was finding out the equation of the plane a(sb)c, and project the point td on to abc, and then solve for intersection to get q. Then do the same for p, and then add and divide them by 2 to get r. But, without knowing t and s, I'm wondering whether this is the right way to go. Any help on this problem would be appreciated.
Find solution for $s$ and $t$ by
$$ \begin{aligned} s & = \frac{(b\cdot d) \left( (a \cdot d)-(b \cdot c) \right)-(a \cdot d)(c \cdot d)}{(b \cdot d)^2-1} \\ t & = \frac{(b\cdot d) \left( (c \cdot d)-(a \cdot d) \right)-(b \cdot c)(a \cdot b)}{(b \cdot d)^2-1} \\ \end{aligned} $$
where ${\cdot}$ is the dot product.
The mid point is then $r=\frac{1}{2} ( a+c+b t+d s)$
HOW ?
Point $p$ is closest point on line $c+sd$ to point $q$, and point $q$ is closest on line $a+b t$ to $p$.
The above leads to $$a+b t = c+ d s + \frac{(a \times b)\times b}{b \cdot b} $$ and $$c+ d s = a+b t + \frac{(c \times d)\times d}{d \cdot d} $$
I can dispose the cross products by projecting along $b$ and $d$
$$ b \cdot (a+b t) = b \cdot (c+d s) + 0 $$ $$ d \cdot (c+d s) = d \cdot (a+b t) + 0 $$
This is two scalar equations solvable for $t$ and $s$.