I have some vector line, which is in the $x$-$y$ plane, say $$\vec{a} = t\left(\begin{matrix} 1 \\ M \\ 0 \end{matrix}\right),$$ and some other general vector, $$\vec{b} = \left(\begin{matrix} a \\ b \\ c \end{matrix}\right)+ s\left(\begin{matrix} d \\ e \\ f \end{matrix}\right).$$
The two vectors are not parallel, and can be considered to extend infinitely. I want to rotate $\vec{a}$ around the y-axis by $\varphi$, until it for some $\varphi$ intersects $\vec{b}$. I don't care what the values of $t$, or $s$ are. By applying the rotation to $\vec a$, and then equating that to $\vec b$, you get the equation: $$t\left(\begin{matrix} \cos \varphi \\ M \\ -\sin \varphi \end{matrix}\right) = \left(\begin{matrix} a \\ b \\ c \end{matrix}\right)+ s\left(\begin{matrix} d \\ e \\ f \end{matrix}\right).$$
By equating components, I can solve this equation. The solutions are immense though, I've included one at the end of the post to give a flavour.
I was very surprised at the complexity of the answer, given intuitively it feels like such a simple operation. Hence I wonder if there's a more simple/beautiful way of solving this problem.
Sample solution for $\varphi$: $$\cos \varphi = \left( \sqrt{(\text{e} \text{a}-\text{d} \text{b})^2 \left(\text{b}^2 \left(\text{d}^2+\text{f}^2\right)-2 \text{e} \text{b} (\text{d} \text{a}+\text{f} \text{c})-M ^2 (\text{f} \text{a}-\text{d} \text{c})^2+\text{e}^2 \left(\text{a}^2+\text{c}^2\right)\right)} + \\M (\text{f} \text{a}-\text{d} \text{c}) (\text{f} \text{b}-\text{e} \text{c}) \right) / \left( \text{b}^2 \left(\text{d}^2+\text{f}^2\right)-2 \text{e} \text{b} (\text{d} \text{a}+\text{f} \text{c})+\text{e}^2 \left(\text{a}^2+\text{c}^2\right) \right)$$
The rotation of line $\vec a$ around the $y$-axis produces a conical surface, whose equation is:
$$ (M-y)^2=M^2(x^2+z^2). $$
Thus, a rotated copy of $\vec a$ intersects line $\vec b$ if and only if line $\vec b$ intersects the cone, that is if there exists some $s$ such that: $$ (M-b-se)^2=M^2[(a+sd)^2+(c+sf)^2]. $$ This is a quadratic equation in $s$: if it has solutions, then you can find the point(s) where the rotated $\vec a$ meets $\vec b$. Once you have an intersection point, it is easy to find the corresponding rotation angle, if needed.