How to check if the connection between two points in the surface of two spheres doesn't collide with any of the spheres

91 Views Asked by At

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.

connections!

2

There are 2 best solutions below

0
On BEST ANSWER

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.$

0
On

If $c_i$ is center of spheres $S_i$, then we define a map $$ f : S_1\times S_2 \rightarrow \mathbb{R}^2,\ f(x,y)=\bigg( \langle c_1-x,x-y\rangle,\langle c_2-y,x-y\rangle \bigg) $$

Then there is no collision iff for $(x,y)\in S_1\times S_2 $, $(x,y)\in f^{-1}( \overrightarrow{0 } ) $.