find ANY point of tangency from a point to a sphere using spherical coordinates

152 Views Asked by At

I have a point $B$ in 3d space.

I also have sphere with centre $C$ and radius $R$.

I'm trying to find ANY point of tangency $T$ from that point $B$ to that sphere using spherical coordinates.

So something like this:

$$Tx = Cx + R*sin(\theta)*cos(\phi)$$

$$Ty = Cy + R*sin(\phi)$$

$$Tz = Cz + R*cos(\theta)*cos(\phi)$$

What would $\theta$ and $\phi$ be in this case? enter image description here

1

There are 1 best solutions below

3
On BEST ANSWER

Without loss of generality let $C$ be the origin and $R=1$. (You can dilate and translate it.)

Let $B$ have coordinates $(a,b,c)$.

You are looking for points $T=(\sin\theta\cos\phi,\sin\phi,\cos\theta\cos\phi)$ such that $T\cdot(B-T)=0$.

$$(\sin\theta\cos\phi,\sin\phi,\cos\theta\cos\phi).((\sin\theta\cos\phi,\sin\phi,\cos\theta\cos\phi)-(a,b,c))=0$$

$$\cos\phi\sin\theta(\cos\phi\sin\theta-a)+\sin\phi(\sin\phi-b)+\cos\phi\cos\theta(\cos\phi\cos\theta-c)=0$$

$$\cos^2\phi\sin^2\theta-a\cos\phi\sin\theta+\sin^2\phi-b\sin\phi+\cos^2\phi\cos^2\theta-c\cos\phi\cos\theta=0$$

$$1-b\sin\phi-\cos\phi(a\sin\theta+c\cos\theta)=0$$

$$a\sin\theta+c\cos\theta=\frac{1-b\sin\phi}{cos\phi}$$

$$\sqrt{a^2+c^2}\sin(\theta+\arctan\frac{c}{a})=\frac{1-b\sin\phi}{cos\phi}$$

$$\theta=\arcsin\left(\frac{1-b\sin\phi}{\sqrt{a^2+c^2}cos\phi}\right)-\arctan\frac{c}{a}$$

Now choose a $\phi$ and you can get the corresponding $\theta$.