Given a line with first end point P(x1,y1) another end point is unknown, intersect with a circle that located at origin with radius R at only one point(tangent) T(x2,y2). An
Take R as the radius of the circle and D the distance from the external point to the center of the circle such that D > R.
The tanget line makes and angle of \alpha with the line connecting the external point and the center, where
\alpha = arcsin(R/D)
The line connecting the external point (P) and the center (C) makes an angle with the horizontal of
\beta = arctan((C_y - P_y)/(C_x - P_x))
That gives you the angle of the tangent line with the horizontal as
\theta = \beta +/- \alpha
Note the ambiguity.
The length of the tangent segment is
L = sqrt(D^2 - R^2)
which is all you need.