# Shortest distance between two points , when you can't cross sphere in the middle

You are given three coordinates and radius of sphere: $$\begin{split} x_1,y_1,z_1 &= \text{ start point};\\ x_2,y_2,z_2 &= \text{ finish point};\\ x_3,y_3,z_3 &= \text{ sphere center};\\ r &= \text{ sphere radius}; \end{split}$$ Find shortest distance between start and finish without crossing sphere. Start and end are not necessary on sphere.

On my observations we need to find two tangent lines which go through start(finish) and arc between tangent line-sphere touching point.

• @Blue I don't think this is a duplicate; in the linked question, it is assumed that the points are on the surface of the sphere, which is not assumed here. – Milo Brandt Jan 24 at 18:59
• @MiloBrandt: Perhaps you're right; it's a little hard to tell, but I guess the question deserves the benefit of the doubt. – Blue Jan 24 at 19:02
• @Blue: But those points of intersection will never be on the shortest path. – TonyK Jan 24 at 20:23