I want to make a connection between the points at the surface of two separate spheres, with the condition that it cannot go through neither of the two spheres. (this connection is simply a line, it could be considered as a vector starting and ending" at those two points).
For this, I have two spheres with their respective local coordinate systems ($k$ being a surface normal to that sphere, and $i$ and $j$ perpendicular vectors to it) an axis and center points in a global coordinate system, from which I have calculated the connection points in the global coordinate system (let's call said connection points $p1$ and $p2$)
While getting said points and the vector between them was trivial, I am not sure how to check whether the resulting vector collides with any of those spheres.
I know that I should form and use a change of basis matrix, but I don't know how to exactly apply it for this.
Any help is appreciated.

We have $P_1$ on the surface of sphere $S_1.$ $N_1$ is normal to $S_1$ at $P_1$
And $P_2$ on the surface of sphere $S_2.$ $N_2$ is normal to $S_2$ at $P_2$
And line $L = P_1 + (P_2-P_1)t$ between these two points.
$N_1\cdot(P_2-P_1) \ge 0$ and $N_2\cdot (P_1-P_2)\ge 0$ indicate $N_1,N_2$ form acute (or right) angles to $L.$