Calculate the distance from a point to the surface of a circle at an angle 
Given:
  A circle C with radius R and center (x,y),
  A point P at (q,r) some distance d away from the circle at its center line, and at a certain height above that center line h, and
  An angle of displacement a,
Find the distance from the point P to the circle for both cases: when the angle $a$ is zero and when the angle $a$ is greater than zero.
Looking forward to whatever solution or even advice someone might be able to give me in order to solve this! Thanks in advance!
 A: So, we need to find out the distance $PA$ as a function of $\alpha$, including the special case $\alpha =0$. It is a quite interesting and challenging problem.

Let $\beta=∠ACB$ and apply the tangent formula to the right triangle APD,
$$\tan\alpha = \frac{AD}{PD}=\frac{R\sin\beta - h}{R+d-R\cos\beta}$$
Rearrange above equation to express $\beta$ in terms of $\alpha$,
$$R\sin(\beta+\alpha)=(R+d)\sin\alpha + h\cos\alpha$$
$$\beta = \sin^{-1} u -\alpha \tag{1}$$
where,
$$u = \left(1+\frac{d}{R}\right)\sin\alpha + \frac{h}{R}\cos\alpha \tag{2}$$
Next, apply the cosine formula to the right triangle APD to write the distance $PA$ as,
$$PA(\alpha) =\frac{R+d-R\cos\beta}{\cos\alpha}\tag{3} $$
With (1), we evaluate $R\cos\beta$ in above expression to get,
$$R\cos\beta = R\sqrt{1-u^2} \cos\alpha + (R+d)\sin^2\alpha + h\cos\alpha\sin\alpha \tag{4}$$ 
Plug (2) into (4) and then into into (3), we arrive at the following result,
$$PA(\alpha) =(R+d)\cos\alpha -h\sin\alpha - \sqrt{R^2-[ (R+d)\sin\alpha + h\cos\alpha ]^2} \tag{5}$$
As seen, the distance $PA$ varies with the angle $\alpha$ in a non-trivial way.
Now, consider the special case of $\alpha = 0$. The general result (5) then simplifies greatly,
$$PA(0) = R + d -\sqrt{R^2-h^2}$$
A: Shift the axes by $(-x,-y),$ so that the negative $x$-axis now lies along the line segment of distance $d$ and the circle is now centred at the origin. Our fixed point $P$ has the coordinates $(q-x,r-y)=(-d,h).$ Since the angle $a$ of the inclination of the line from $P$ to the circle is also given, the line satisfying those conditions has the equation $y-h=(x+d)\tan a.$
Finally, let $Q$ be a point both on the circle $x^2+y^2=R^2$ and on the line. Then we want to find $\overline{PQ}.$ We could do this by first finding the intersection $Q$ of the line and the circle (solving the system defined), and then applying the euclidean distance formula.
A: Considering differential relations exaggerated 

$$ da= \frac{R d\theta \, \cos \theta}{m}$$
Integrate
$$ a=  \frac{R  \sin \theta}{m} + c $$
Initial condition
$$ R \sin\theta = h,\, a=0 $$
so that
$$ m\, a = R \sin\theta -h. $$
A: One general approach is to extend the line from $P = (q,r)$ indefinitely in whatever direction is given.
Drop a perpendicular to that line from $O = (x,y).$
Suppose the perpendicular intersects the line at $Q.$
Compute the distance $PQ$ and the distance $OQ.$
Given $OQ$ and the radius $R,$ you can use the Pythagorean Theorem to 
compute the distance $BQ$ between $Q$ and the point where the line meets the circle:
$$ BQ = \sqrt{R^2 - (OQ)^2}.$$
Subtract this from $PQ$ and you have the distance to the circle.
There are various ways to find the lengths $PQ$ and $OQ$ without actually finding the coordinates of $Q.$
One way is to set up unit-length vectors parallel and perpendicular to the line through $P.$
Take the dot product of the vector $OP$ with each of those vectors;
the absolute values give you the two distances.
Another way is to compute the angle $\angle OPQ,$ which you can do if you know the angle between $OP$ and the line marked $d$ and you also know the angle $a.$
Now you have one of the angles of the right triangle $\triangle OPQ,$
and you can use that angle, the known hypotenuse $OP$ of that triangle,
and some trigonometry to find the two legs $OQ$ and $PQ.$
