[Math] Tangents to a circle in 3D

3dcirclesgeometrytangent line

I couldn't find this question asked for the 3D case; so here goes:

I have a circle given by the center $c=(x_c,y_c,z_c)$ and the normal $n=(x_n,y_n,z_n),||n||=1$.

Further, I have a point $p=(x_p,y_p,z_p)$ that is guaranteed to be in the same plane of the circle and also outside of the circle.

I am looking for a closed form for the two tangents from $p$ to the circle.

My idea is to get the formula for the circle from here Parametric Equation of a Circle in 3D Space?:

$\left(\matrix{x\\y\\z}\right)=c+r\cdot \cos(\theta)\cdot a+r\cdot \sin(\theta)\cdot b$

($a, b, r$ are known) and set it equal to the other required property:

$\left(\matrix{x-x_c\\y-y_c\\z-z_c}\right).\left(\matrix{x-x_p\\y-y_p\\z-z_p}\right)=0$

But I don't know where to go from there.

Thanks in advance!

Best Answer

Translate everything by $-c$ so that the circle center goes to the origin and $p$ goes to $p'$. Now take the cross product of the vectors $n$ and $p'$, let $q$. Normalize $p'$ and $q$ to be unit vectors. Now the matrix $R$ formed by $p',q,n$ is a rotation matrix that applies the plane $oxy$ to the plane $op'q$ and the axis $ox$ to $op'$.

Take the transpose of this orthogonal matrix, which is its inverse and perform the inverse rotation.

You now have a circle in the plane $oxy$, centered at the origin, and a point $p''$ on the $ox$ axis. By trigonometry, it is not a big deal to find the tangency points. (Check https://en.wikipedia.org/wiki/Tangent_lines_to_circles.)

Apply the rotation followed by the reverse translation to obtain the coordinates in the original system of axis.