Find intersection between line and sphere have the following problem developing a 3D game!
A one line through P, intersects the sphere in T , line PT tangent.
I know P (x , y, z ) the vector v(vx,vy,vz), the center C ( 0,0,0) and ray R of the sphere.
it is essential T lie to plane made of P+v and PC.All lines P+v, PT and PC are coplanar. 
I'm not sure if knowing the radius help on something, however these are known data of problem.
The main question is :
Discover the T point or a tangente plane that just touch the surface of sphere at the point T.
I am not sure there is a solution or missing something..
anyway, Thanks for all!


 A: From the setup, we can assume that $v$ is not parallel to $PC$, or there's no solution. 
$$
\newcommand{\u}{ {\mathbf u} }
\newcommand{\v}{ {\mathbf v} }
\newcommand{\w}{ {\mathbf w} }
$$
Let 
\begin{align}
\u &= (C-P)  \\
\u^\perp &= \v -  \frac{(\v \cdot \u) \u}{\|\u\|^2} \\
\v &= \| \u \| \frac{\u^\perp}{\|\u^\perp \|}
\end{align}
Then $\u$ and $\v$ are perpendicular and the same length, and $T - P$ is a combination of $\u$ and $\v$. 
Looking at the right triangle $P T C$, with right angle at $T$, we see that the angle $\theta$ between $PC$ and $PT$ must have
$$
\sin\theta = \frac{R}{\|\u\|}
$$
So the vector $\w = T-P$ must be
$$
\w = k( \cos( \theta) \u + \sin( \theta) \v)
$$
for some value of $k$. 
We know that $k^2 + R^2 = \| \u\|^2$, so 
$$
\w = \sqrt{\|\u\|^2 - R^2}( \cos( \theta) \u + \sin( \theta) \v)
$$
and 
$$
T = P + \sqrt{\|\u\|^2 - R^2}( \cos( \theta) \u + \sin( \theta) \v)
$$
A: From the second diagram, it is clear that the angle between $v$ and the line $PC$ does not matter. The length of $v$ also does not matter.
The only thing we need from $v$ is to determine the plane in which $T$ must lie.
So let $u = C - P$, and let
$$v_\perp = v - \frac{v\cdot u}{\|u\|^2} u.$$
Then $u$ and $v_\perp$ are perpendicular and lie in the desired plane.
Since $\triangle PTC$ is a right triangle with right angle at $T$,
the distance $PT$ is found by solving
$$(PT)^2 + (CT)^2 = (PC)^2,$$
that is,
$$(PT)^2 = (PC)^2 - (CT)^2 = \|u\|^2 - R^2.$$
Now drop a perpendicular line from $T$ to $PC$ and call the intersection $D$.
Then $\triangle PDT$ is similar to $\triangle PTC$;
in particular,
$\frac{PD}{PT} = \frac{PT}{PC}$
and
$\frac{TD}{PT} = \frac{CT}{PC}.$
This gives us
$$PD = \frac{(PT)^2}{PC} = \frac{\|u\|^2 - R^2}{\|u\|}$$
and
$$TD = \frac{(CT)(PT)}{PC} = \frac{R \sqrt{\|u\|^2 - R^2}}{\|u\|}.$$
Finally, the vector $T-P$ has components 
$D - P$ (which is parallel to $u$)
and $T-D$  (which is parallel to $v_\perp$), and we know the lengths of these
components are $PD$ and $TD$, respectively, so
$$T - P = (PD)\frac{u}{\|u\|} + (TD)\frac{v_\perp}{\|v_\perp\|}.$$
Plug in the values and vectors already found, and you can locate $T$.
