how to compute a plane tangent to a sphere - parameters of the plane partially known

I would like to compute the plane which is tangent with a given sphere (see Fig 1 on the attached figure).

Known parameters are the following:

• Point P (§x_1, y_1, z_1§) belongs to the plane. One “orientation” of the plane is given by the vector §_vec{u}§
• The center of the sphere § x_c y_c z_c § and its radius R are known

On Fig 2 on the attached figure, I try to explain why I am facing such problem. I have developed a humanoid robot with a thigh which makes an angle with respect to the leg. It means that there is always a constant distance (R) – whatever the rotation of the thigh is - between the Pelvic and the leg.The foot is articulated with a forefoot and a midfoot.

If I want to compute the orientation of the leg and thigh with respect to a given position of the Pelvic and the Foot, I come with the geometrical problem of computing a plane tangent with a sphere whose center is the extremity of the Pelvic.

I hope that the problem is clearly explained and if somebody can provide an answer it will be wonderful enter image description here

These parameters are not enough. For most points $P$ and vectors $u$, there are two planes containing both $P$ and $u$ and tangent to the sphere. On the other hand, if the ray $P + tu$ ($t \in \Bbb R$) intersects the sphere in two points, then there is no such plane. Let's assume that $u$ is a unit vector to make things simpler; otherwise, replace $u$ by $u/\|u\|$. The you can actually determine the point $Q$ on the ray $P + tu$ that's closest to the sphere-center $C$ by solving for $t$. If $T$ is the point of tangency, then $Q-T$ is both perpendicular to $C-T$ (by tangency) and to $u$ (because $Q$ is the closest point to $C$ along the ray). And $\| C - T \| = R$. Together, these give you two possible solutions for $T$. (It's probably easiest to write $$T = C + R \cos (b) v + R \sin(b) w$$ where $u, v, w$ is an orthonormal basis with $v$ parallel to $Q-C$; then you can solve for $b$, which will give you two possible values, corresponding to the two solution planes.
• Thank you very much for your answer. I agree that the number of parameters are not enough and that I will come up with two solutions in any case.If I follow you, I need an iterative process to solve $t$ - I cannot find it analytically? $v$ is parallel to $Q-C$ and $w$ = $Q-T$ ? I also found a link with a question similar to mine here [link] (math.stackexchange.com/questions/1835853/…) – fabrice Feb 5 '17 at 7:46
• Nah...you can find the minimizing value $t_0$ analytically, because $u \cdot (P + t_0u - C) = 0$; that tells you that $t_0 + u \cdot (P - C) = 0$, so $t_0 = u \cdot (C - P)$ (assuming I haven't screwed up the algebra here by typing without writing it out first). – John Hughes Feb 5 '17 at 14:09
Thank you for clarifying the answer, actually to be sure I understood your reasoning I posted a picture. Q is on the $P + t\vec{u}$, the $\vec{u}$ I defined in the previous picture. $\vec{v}$ is along the $Q-C$. Is it correct? Thank you for your help